提交 91dd1156 编写于 作者: B Behdad Esfahbod

Add HB_NDEBUG

API changes:
- If NDEBUG is defined, define HB_NDEBUG
- Disable costlier sanity checks if HB_NDEBUG is defined.

In 1.2.3 introduced some code to disable costly sanity checks if
NDEBUG is defined.  NDEBUG, however, disables all assert()s as
well.  With HB_NDEBUG, one can disable costlier checks but keep
assert()s.

I'll probably add a way to define HB_NDEBUG automatically in
release tarballs.  But for now, production systems that do NOT
define NDEBUG, are encouraged to define HB_NDEBUG for our build.
上级 75568b0a
...@@ -130,7 +130,7 @@ pkgconfig_DATA = harfbuzz.pc ...@@ -130,7 +130,7 @@ pkgconfig_DATA = harfbuzz.pc
EXTRA_DIST += harfbuzz.pc.in EXTRA_DIST += harfbuzz.pc.in
FUZZING_CPPFLAGS= \ FUZZING_CPPFLAGS= \
-DNDEBUG \ -DHB_NDEBUG \
-DHB_MAX_NESTING_LEVEL=3 \ -DHB_MAX_NESTING_LEVEL=3 \
-DHB_SANITIZE_MAX_EDITS=3 \ -DHB_SANITIZE_MAX_EDITS=3 \
-DHB_BUFFER_MAX_EXPANSION_FACTOR=3 \ -DHB_BUFFER_MAX_EXPANSION_FACTOR=3 \
......
...@@ -124,7 +124,7 @@ struct hb_buffer_t { ...@@ -124,7 +124,7 @@ struct hb_buffer_t {
void *message_data; void *message_data;
hb_destroy_func_t message_destroy; hb_destroy_func_t message_destroy;
#ifndef NDEBUG #ifndef HB_NDEBUG
/* Internal debugging. */ /* Internal debugging. */
/* These reflect current allocations of the bytes in glyph_info_t's var1 and var2. */ /* These reflect current allocations of the bytes in glyph_info_t's var1 and var2. */
uint8_t allocated_var_bytes[8]; uint8_t allocated_var_bytes[8];
...@@ -260,7 +260,7 @@ struct hb_buffer_t { ...@@ -260,7 +260,7 @@ struct hb_buffer_t {
#define HB_BUFFER_XALLOCATE_VAR(b, func, var, owner) \ #define HB_BUFFER_XALLOCATE_VAR(b, func, var, owner) \
b->func (offsetof (hb_glyph_info_t, var) - offsetof(hb_glyph_info_t, var1), \ b->func (offsetof (hb_glyph_info_t, var) - offsetof(hb_glyph_info_t, var1), \
sizeof (b->info[0].var), owner) sizeof (b->info[0].var), owner)
#ifndef NDEBUG #ifndef HB_NDEBUG
#define HB_BUFFER_ALLOCATE_VAR(b, var) \ #define HB_BUFFER_ALLOCATE_VAR(b, var) \
HB_BUFFER_XALLOCATE_VAR (b, allocate_var, var (), #var) HB_BUFFER_XALLOCATE_VAR (b, allocate_var, var (), #var)
#define HB_BUFFER_DEALLOCATE_VAR(b, var) \ #define HB_BUFFER_DEALLOCATE_VAR(b, var) \
......
...@@ -661,7 +661,7 @@ hb_buffer_t::guess_segment_properties (void) ...@@ -661,7 +661,7 @@ hb_buffer_t::guess_segment_properties (void)
} }
#ifndef NDEBUG #ifndef HB_NDEBUG
static inline void static inline void
dump_var_allocation (const hb_buffer_t *buffer) dump_var_allocation (const hb_buffer_t *buffer)
{ {
...@@ -729,7 +729,7 @@ void hb_buffer_t::deallocate_var_all (void) ...@@ -729,7 +729,7 @@ void hb_buffer_t::deallocate_var_all (void)
memset (allocated_var_bytes, 0, sizeof (allocated_var_bytes)); memset (allocated_var_bytes, 0, sizeof (allocated_var_bytes));
memset (allocated_var_owner, 0, sizeof (allocated_var_owner)); memset (allocated_var_owner, 0, sizeof (allocated_var_owner));
} }
#endif /* NDEBUG */ #endif /* HB_NDEBUG */
/* Public API */ /* Public API */
......
...@@ -611,6 +611,15 @@ static inline unsigned char TOLOWER (unsigned char c) ...@@ -611,6 +611,15 @@ static inline unsigned char TOLOWER (unsigned char c)
/* Debug */ /* Debug */
/* HB_NDEBUG disables some sanity checks that are very safe to disable and
* should be disabled in production systems. If NDEBUG is defined, enable
* HB_NDEBUG; but if it's desirable that normal assert()s (which are very
* light-weight) to be enabled, then HB_DEBUG can be defined to disable
* the costlier checks. */
#ifdef NDEBUG
#define HB_NDEBUG
#endif
#ifndef HB_DEBUG #ifndef HB_DEBUG
#define HB_DEBUG 0 #define HB_DEBUG 0
#endif #endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册