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.
pull/231/head
Behdad Esfahbod 9 years ago
parent 75568b0a7f
commit 91dd115652
  1. 2
      src/Makefile.am
  2. 4
      src/hb-buffer-private.hh
  3. 4
      src/hb-buffer.cc
  4. 9
      src/hb-private.hh

@ -130,7 +130,7 @@ pkgconfig_DATA = harfbuzz.pc
EXTRA_DIST += harfbuzz.pc.in
FUZZING_CPPFLAGS= \
-DNDEBUG \
-DHB_NDEBUG \
-DHB_MAX_NESTING_LEVEL=3 \
-DHB_SANITIZE_MAX_EDITS=3 \
-DHB_BUFFER_MAX_EXPANSION_FACTOR=3 \

@ -124,7 +124,7 @@ struct hb_buffer_t {
void *message_data;
hb_destroy_func_t message_destroy;
#ifndef NDEBUG
#ifndef HB_NDEBUG
/* Internal debugging. */
/* These reflect current allocations of the bytes in glyph_info_t's var1 and var2. */
uint8_t allocated_var_bytes[8];
@ -260,7 +260,7 @@ struct hb_buffer_t {
#define HB_BUFFER_XALLOCATE_VAR(b, func, var, owner) \
b->func (offsetof (hb_glyph_info_t, var) - offsetof(hb_glyph_info_t, var1), \
sizeof (b->info[0].var), owner)
#ifndef NDEBUG
#ifndef HB_NDEBUG
#define HB_BUFFER_ALLOCATE_VAR(b, var) \
HB_BUFFER_XALLOCATE_VAR (b, allocate_var, var (), #var)
#define HB_BUFFER_DEALLOCATE_VAR(b, var) \

@ -661,7 +661,7 @@ hb_buffer_t::guess_segment_properties (void)
}
#ifndef NDEBUG
#ifndef HB_NDEBUG
static inline void
dump_var_allocation (const hb_buffer_t *buffer)
{
@ -729,7 +729,7 @@ void hb_buffer_t::deallocate_var_all (void)
memset (allocated_var_bytes, 0, sizeof (allocated_var_bytes));
memset (allocated_var_owner, 0, sizeof (allocated_var_owner));
}
#endif /* NDEBUG */
#endif /* HB_NDEBUG */
/* Public API */

@ -611,6 +611,15 @@ static inline unsigned char TOLOWER (unsigned char c)
/* 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
#define HB_DEBUG 0
#endif

Loading…
Cancel
Save