[Mesa-dev] [PATCH 1/2] Change a few frequented uses of DEBUG to !NDEBUG

Marek Olšák maraeo at gmail.com
Fri May 10 05:21:15 UTC 2019


From: Marek Olšák <marek.olsak at amd.com>

debugoptimized builds don't define NDEBUG, but they also don't define
DEBUG. We want to enable cheap debug code for these builds.
I only chose those occurences that I care about.
---
 src/gallium/auxiliary/tgsi/tgsi_ureg.c              | 2 +-
 src/gallium/drivers/radeonsi/si_descriptors.c       | 2 +-
 src/gallium/drivers/radeonsi/si_pipe.h              | 2 +-
 src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c | 6 +++---
 src/gallium/drivers/radeonsi/si_state.c             | 4 ++--
 src/mesa/main/context.c                             | 2 +-
 src/mesa/main/debug.c                               | 4 ++--
 src/mesa/main/errors.c                              | 6 +++---
 src/mesa/main/feedback.c                            | 2 +-
 src/mesa/main/formats.c                             | 2 --
 src/mesa/main/imports.c                             | 4 ++--
 src/mesa/main/mtypes.h                              | 2 +-
 src/mesa/main/shaderapi.c                           | 2 +-
 src/mesa/state_tracker/st_atom_framebuffer.c        | 2 +-
 src/mesa/state_tracker/st_format.c                  | 2 +-
 src/mesa/vbo/vbo_exec.h                             | 2 +-
 src/mesa/vbo/vbo_exec_api.c                         | 6 +++---
 src/util/slab.c                                     | 4 ++--
 18 files changed, 27 insertions(+), 29 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index c1c8851486e..55ed7fc62b4 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -1234,21 +1234,21 @@ ureg_emit_dst( struct ureg_program *ureg,
    }
 
    assert(n == size);
 }
 
 
 static void validate( enum tgsi_opcode opcode,
                       unsigned nr_dst,
                       unsigned nr_src )
 {
-#ifdef DEBUG
+#ifndef NDEBUG
    const struct tgsi_opcode_info *info = tgsi_get_opcode_info( opcode );
    assert(info);
    if (info) {
       assert(nr_dst == info->num_dst);
       assert(nr_src == info->num_src);
    }
 #endif
 }
 
 struct ureg_emit_insn_result
diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c
index 6a4dcacc0f3..68b5430446e 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -953,21 +953,21 @@ static void si_bind_sampler_states(struct pipe_context *ctx,
 		return;
 
 	for (i = 0; i < count; i++) {
 		unsigned slot = start + i;
 		unsigned desc_slot = si_get_sampler_slot(slot);
 
 		if (!sstates[i] ||
 		    sstates[i] == samplers->sampler_states[slot])
 			continue;
 
-#ifdef DEBUG
+#ifndef NDEBUG
 		assert(sstates[i]->magic == SI_SAMPLER_STATE_MAGIC);
 #endif
 		samplers->sampler_states[slot] = sstates[i];
 
 		/* If FMASK is bound, don't overwrite it.
 		 * The sampler state will be set after FMASK is unbound.
 		 */
 		struct si_sampler_view *sview =
 			(struct si_sampler_view *)samplers->views[slot];
 
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h
index 4061bf139fb..2f1acec8ef2 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -596,21 +596,21 @@ struct si_sampler_view {
 	ubyte				base_level;
 	ubyte				block_width;
 	bool is_stencil_sampler;
 	bool is_integer;
 	bool dcc_incompatible;
 };
 
 #define SI_SAMPLER_STATE_MAGIC 0x34f1c35a
 
 struct si_sampler_state {
-#ifdef DEBUG
+#ifndef NDEBUG
 	unsigned			magic;
 #endif
 	uint32_t			val[4];
 	uint32_t			integer_val[4];
 	uint32_t			upgraded_depth_val[4];
 };
 
 struct si_cs_shader_state {
 	struct si_compute		*program;
 	struct si_compute		*emitted_program;
diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
index 3ec919dd23b..f70c41ca8c4 100644
--- a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
+++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
@@ -644,21 +644,21 @@ static void emit_declaration(struct lp_build_tgsi_context *bld_base,
 				ctx->temp_array_allocas[id] = array_alloca;
 			}
 		}
 
 		if (!ctx->temps_count) {
 			ctx->temps_count = bld_base->info->file_max[TGSI_FILE_TEMPORARY] + 1;
 			ctx->temps = MALLOC(TGSI_NUM_CHANNELS * ctx->temps_count * sizeof(LLVMValueRef));
 		}
 		if (!array_alloca) {
 			for (i = 0; i < decl_size; ++i) {
-#ifdef DEBUG
+#ifndef NDEBUG
 				snprintf(name, sizeof(name), "TEMP%d.%c",
 					 first + i / 4, "xyzw"[i % 4]);
 #endif
 				ctx->temps[first * TGSI_NUM_CHANNELS + i] =
 					ac_build_alloca_undef(&ctx->ac,
 							      ctx->f32,
 							      name);
 			}
 		} else {
 			LLVMValueRef idxs[2] = {
@@ -674,21 +674,21 @@ static void emit_declaration(struct lp_build_tgsi_context *bld_base,
 				 * a shader ever reads from a channel that
 				 * it never writes to.
 				 */
 				ctx->undef_alloca = ac_build_alloca_undef(
 					&ctx->ac, ctx->f32, "undef");
 			}
 
 			for (i = 0; i < decl_size; ++i) {
 				LLVMValueRef ptr;
 				if (writemask & (1 << (i % 4))) {
-#ifdef DEBUG
+#ifndef NDEBUG
 					snprintf(name, sizeof(name), "TEMP%d.%c",
 						 first + i / 4, "xyzw"[i % 4]);
 #endif
 					idxs[1] = LLVMConstInt(ctx->i32, j, 0);
 					ptr = LLVMBuildGEP(builder, array_alloca, idxs, 2, name);
 					j++;
 				} else {
 					ptr = ctx->undef_alloca;
 				}
 				ctx->temps[first * TGSI_NUM_CHANNELS + i] = ptr;
@@ -728,21 +728,21 @@ static void emit_declaration(struct lp_build_tgsi_context *bld_base,
 	case TGSI_FILE_OUTPUT:
 	{
 		char name[16] = "";
 		unsigned idx;
 		for (idx = decl->Range.First; idx <= decl->Range.Last; idx++) {
 			unsigned chan;
 			assert(idx < RADEON_LLVM_MAX_OUTPUTS);
 			if (ctx->outputs[idx][0])
 				continue;
 			for (chan = 0; chan < TGSI_NUM_CHANNELS; chan++) {
-#ifdef DEBUG
+#ifndef NDEBUG
 				snprintf(name, sizeof(name), "OUT%d.%c",
 					 idx, "xyzw"[chan % 4]);
 #endif
 				ctx->outputs[idx][chan] = ac_build_alloca_undef(
 					&ctx->ac, ctx->f32, name);
 			}
 		}
 		break;
 	}
 
diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
index 876a993b158..54298c056bb 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -4312,21 +4312,21 @@ static void *si_create_sampler_state(struct pipe_context *ctx,
 	struct si_sampler_state *rstate = CALLOC_STRUCT(si_sampler_state);
 	unsigned max_aniso = sscreen->force_aniso >= 0 ? sscreen->force_aniso
 						       : state->max_anisotropy;
 	unsigned max_aniso_ratio = si_tex_aniso_filter(max_aniso);
 	union pipe_color_union clamped_border_color;
 
 	if (!rstate) {
 		return NULL;
 	}
 
-#ifdef DEBUG
+#ifndef NDEBUG
 	rstate->magic = SI_SAMPLER_STATE_MAGIC;
 #endif
 	rstate->val[0] = (S_008F30_CLAMP_X(si_tex_wrap(state->wrap_s)) |
 			  S_008F30_CLAMP_Y(si_tex_wrap(state->wrap_t)) |
 			  S_008F30_CLAMP_Z(si_tex_wrap(state->wrap_r)) |
 			  S_008F30_MAX_ANISO_RATIO(max_aniso_ratio) |
 			  S_008F30_DEPTH_COMPARE_FUNC(si_tex_compare(state->compare_func)) |
 			  S_008F30_FORCE_UNNORMALIZED(!state->normalized_coords) |
 			  S_008F30_ANISO_THRESHOLD(max_aniso_ratio >> 1) |
 			  S_008F30_ANISO_BIAS(max_aniso_ratio) |
@@ -4391,21 +4391,21 @@ static void si_emit_sample_mask(struct si_context *sctx)
 	assert(mask == 0xffff || sctx->framebuffer.nr_samples > 1 ||
 	       (mask & 1 && sctx->blitter->running));
 
 	radeon_set_context_reg_seq(cs, R_028C38_PA_SC_AA_MASK_X0Y0_X1Y0, 2);
 	radeon_emit(cs, mask | (mask << 16));
 	radeon_emit(cs, mask | (mask << 16));
 }
 
 static void si_delete_sampler_state(struct pipe_context *ctx, void *state)
 {
-#ifdef DEBUG
+#ifndef NDEBUG
 	struct si_sampler_state *s = state;
 
 	assert(s->magic == SI_SAMPLER_STATE_MAGIC);
 	s->magic = 0;
 #endif
 	free(state);
 }
 
 /*
  * Vertex elements & buffers
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 2c3d9a11ce3..a86c4e31671 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -934,21 +934,21 @@ update_default_objects(struct gl_context *ctx)
  * \param name  the name of the OpenGL function
  */
 #if USE_GLAPI_NOP_FEATURES
 static void
 nop_handler(const char *name)
 {
    GET_CURRENT_CONTEXT(ctx);
    if (ctx) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid call)", name);
    }
-#if defined(DEBUG)
+#ifndef NDEBUG
    else if (getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")) {
       fprintf(stderr,
               "GL User Error: gl%s called without a rendering context\n",
               name);
       fflush(stderr);
    }
 #endif
 }
 #endif
 
diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c
index db11ae35a25..6ff1abbe24f 100644
--- a/src/mesa/main/debug.c
+++ b/src/mesa/main/debug.c
@@ -133,21 +133,21 @@ void _mesa_print_info( struct gl_context *ctx )
 
 
 /**
  * Set verbose logging flags.  When these flags are set, GL API calls
  * in the various categories will be printed to stderr.
  * \param str  a comma-separated list of keywords
  */
 static void
 set_verbose_flags(const char *str)
 {
-#ifdef DEBUG
+#ifndef NDEBUG
    struct option {
       const char *name;
       GLbitfield flag;
    };
    static const struct option opts[] = {
       { "varray",    VERBOSE_VARRAY },
       { "tex",       VERBOSE_TEXTURE },
       { "mat",       VERBOSE_MATERIAL },
       { "pipe",      VERBOSE_PIPELINE },
       { "driver",    VERBOSE_DRIVER },
@@ -174,21 +174,21 @@ set_verbose_flags(const char *str)
 
 
 /**
  * Set debugging flags.  When these flags are set, Mesa will do additional
  * debug checks or actions.
  * \param str  a comma-separated list of keywords
  */
 static void
 set_debug_flags(const char *str)
 {
-#ifdef DEBUG
+#ifndef NDEBUG
    struct option {
       const char *name;
       GLbitfield flag;
    };
    static const struct option opts[] = {
       { "silent", DEBUG_SILENT }, /* turn off debug messages */
       { "flush", DEBUG_ALWAYS_FLUSH }, /* flush after each drawing command */
       { "incomplete_tex", DEBUG_INCOMPLETE_TEXTURE },
       { "incomplete_fbo", DEBUG_INCOMPLETE_FBO },
       { "context", DEBUG_CONTEXT } /* force set GL_CONTEXT_FLAG_DEBUG_BIT flag */
diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c
index 995b0510575..071b75c4727 100644
--- a/src/mesa/main/errors.c
+++ b/src/mesa/main/errors.c
@@ -52,21 +52,21 @@ output_if_debug(const char *prefixString, const char *outputString,
     */
    if (debug == -1) {
       /* If MESA_LOG_FILE env var is set, log Mesa errors, warnings,
        * etc to the named file.  Otherwise, output to stderr.
        */
       const char *logFile = getenv("MESA_LOG_FILE");
       if (logFile)
          LogFile = fopen(logFile, "w");
       if (!LogFile)
          LogFile = stderr;
-#ifdef DEBUG
+#ifndef NDEBUG
       /* in debug builds, print messages unless MESA_DEBUG="silent" */
       if (MESA_DEBUG_FLAGS & DEBUG_SILENT)
          debug = 0;
       else
          debug = 1;
 #else
       /* in release builds, be silent unless MESA_DEBUG is set */
       debug = getenv("MESA_DEBUG") != NULL;
 #endif
    }
@@ -182,21 +182,21 @@ _mesa_problem( const struct gl_context *ctx, const char *fmtString, ... )
 static GLboolean
 should_output(struct gl_context *ctx, GLenum error, const char *fmtString)
 {
    static GLint debug = -1;
 
    /* Check debug environment variable only once:
     */
    if (debug == -1) {
       const char *debugEnv = getenv("MESA_DEBUG");
 
-#ifdef DEBUG
+#ifndef NDEBUG
       if (debugEnv && strstr(debugEnv, "silent"))
          debug = GL_FALSE;
       else
          debug = GL_TRUE;
 #else
       if (debugEnv)
          debug = GL_TRUE;
       else
          debug = GL_FALSE;
 #endif
@@ -371,21 +371,21 @@ _mesa_error_no_memory(const char *caller)
 /**
  * Report debug information.  Print error message to stderr via fprintf().
  * No-op if DEBUG mode not enabled.
  *
  * \param ctx GL context.
  * \param fmtString printf()-style format string, followed by optional args.
  */
 void
 _mesa_debug( const struct gl_context *ctx, const char *fmtString, ... )
 {
-#ifdef DEBUG
+#ifndef NDEBUG
    char s[MAX_DEBUG_MESSAGE_LENGTH];
    va_list args;
    va_start(args, fmtString);
    _mesa_vsnprintf(s, MAX_DEBUG_MESSAGE_LENGTH, fmtString, args);
    va_end(args);
    output_if_debug("Mesa", s, GL_FALSE);
 #endif /* DEBUG */
    (void) ctx;
    (void) fmtString;
 }
diff --git a/src/mesa/main/feedback.c b/src/mesa/main/feedback.c
index 65f4c35d94e..8b3410f39c5 100644
--- a/src/mesa/main/feedback.c
+++ b/src/mesa/main/feedback.c
@@ -421,21 +421,21 @@ _mesa_RenderMode( GLenum mode )
    switch (ctx->RenderMode) {
       case GL_RENDER:
 	 result = 0;
 	 break;
       case GL_SELECT:
 	 if (ctx->Select.HitFlag) {
 	    write_hit_record( ctx );
 	 }
 	 if (ctx->Select.BufferCount > ctx->Select.BufferSize) {
 	    /* overflow */
-#ifdef DEBUG
+#ifndef NDEBUG
             _mesa_warning(ctx, "Feedback buffer overflow");
 #endif
 	    result = -1;
 	 }
 	 else {
 	    result = ctx->Select.Hits;
 	 }
 	 ctx->Select.BufferCount = 0;
 	 ctx->Select.Hits = 0;
 	 ctx->Select.NameStackDepth = 0;
diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index b47bed97d20..8d6c76a3419 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -727,23 +727,21 @@ _mesa_get_uncompressed_format(mesa_format format)
    case MESA_FORMAT_ETC2_RG11_EAC:
    case MESA_FORMAT_ETC2_SIGNED_RG11_EAC:
       return MESA_FORMAT_R16G16_UNORM;
    case MESA_FORMAT_BPTC_RGBA_UNORM:
    case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM:
       return MESA_FORMAT_A8B8G8R8_UNORM;
    case MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT:
    case MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT:
       return MESA_FORMAT_RGB_FLOAT32;
    default:
-#ifdef DEBUG
       assert(!_mesa_is_format_compressed(format));
-#endif
       return format;
    }
 }
 
 
 GLuint
 _mesa_format_num_components(mesa_format format)
 {
    const struct gl_format_info *info = _mesa_get_format_info(format);
    return ((info->RedBits > 0) +
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index 566aac1d385..f1bcd2fa1f7 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -95,21 +95,21 @@ _mesa_align_malloc(size_t bytes, unsigned long alignment)
 
    assert( alignment > 0 );
 
    ptr = (uintptr_t)malloc(bytes + alignment + sizeof(void *));
    if (!ptr)
       return NULL;
 
    buf = (ptr + alignment + sizeof(void *)) & ~(uintptr_t)(alignment - 1);
    *(uintptr_t *)(buf - sizeof(void *)) = ptr;
 
-#ifdef DEBUG
+#ifndef NDEBUG
    /* mark the non-aligned area */
    while ( ptr < buf - sizeof(void *) ) {
       *(unsigned long *)ptr = 0xcdcdcdcd;
       ptr += sizeof(unsigned long);
    }
 #endif
 
    return (void *) buf;
 #endif /* defined(HAVE_POSIX_MEMALIGN) */
 }
@@ -144,21 +144,21 @@ _mesa_align_calloc(size_t bytes, unsigned long alignment)
 
    assert( alignment > 0 );
 
    ptr = (uintptr_t)calloc(1, bytes + alignment + sizeof(void *));
    if (!ptr)
       return NULL;
 
    buf = (ptr + alignment + sizeof(void *)) & ~(uintptr_t)(alignment - 1);
    *(uintptr_t *)(buf - sizeof(void *)) = ptr;
 
-#ifdef DEBUG
+#ifndef NDEBUG
    /* mark the non-aligned area */
    while ( ptr < buf - sizeof(void *) ) {
       *(unsigned long *)ptr = 0xcdcdcdcd;
       ptr += sizeof(unsigned long);
    }
 #endif
 
    return (void *)buf;
 #endif /* defined(HAVE_POSIX_MEMALIGN) */
 }
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 76905f60662..590527477b5 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -5165,21 +5165,21 @@ struct gl_context
 struct gl_memory_info
 {
    unsigned total_device_memory; /**< size of device memory, e.g. VRAM */
    unsigned avail_device_memory; /**< free device memory at the moment */
    unsigned total_staging_memory; /**< size of staging memory, e.g. GART */
    unsigned avail_staging_memory; /**< free staging memory at the moment */
    unsigned device_memory_evicted; /**< size of memory evicted (monotonic counter) */
    unsigned nr_device_memory_evictions; /**< # of evictions (monotonic counter) */
 };
 
-#ifdef DEBUG
+#ifndef NDEBUG
 extern int MESA_VERBOSE;
 extern int MESA_DEBUG_FLAGS;
 #else
 # define MESA_VERBOSE 0
 # define MESA_DEBUG_FLAGS 0
 #endif
 
 
 /** The MESA_VERBOSE var is a bitmask of these flags */
 enum _verbose
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 2cc5fe5d8f8..584af9b8cef 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -467,21 +467,21 @@ detach_shader(struct gl_context *ctx, GLuint program, GLuint shader,
          }
          while (++i < n) {
             newList[j++] = shProg->Shaders[i];
          }
 
          /* Free old list and install new one */
          free(shProg->Shaders);
          shProg->Shaders = newList;
          shProg->NumShaders = n - 1;
 
-#ifdef DEBUG
+#ifndef NDEBUG
          /* sanity check - make sure the new list's entries are sensible */
          for (j = 0; j < shProg->NumShaders; j++) {
             assert(shProg->Shaders[j]->Stage == MESA_SHADER_VERTEX ||
                    shProg->Shaders[j]->Stage == MESA_SHADER_TESS_CTRL ||
                    shProg->Shaders[j]->Stage == MESA_SHADER_TESS_EVAL ||
                    shProg->Shaders[j]->Stage == MESA_SHADER_GEOMETRY ||
                    shProg->Shaders[j]->Stage == MESA_SHADER_FRAGMENT);
             assert(shProg->Shaders[j]->RefCount > 0);
          }
 #endif
diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c
index f18c40dbe7b..15727fa9d80 100644
--- a/src/mesa/state_tracker/st_atom_framebuffer.c
+++ b/src/mesa/state_tracker/st_atom_framebuffer.c
@@ -181,21 +181,21 @@ st_update_framebuffer_state( struct st_context *st )
          /* rendering to a GL texture, may have to update surface */
          st_update_renderbuffer_surface(st, strb);
       }
       framebuffer.zsbuf = strb->surface;
       if (strb->surface)
          update_framebuffer_size(&framebuffer, strb->surface);
    }
    else
       framebuffer.zsbuf = NULL;
 
-#ifdef DEBUG
+#ifndef NDEBUG
    /* Make sure the resource binding flags were set properly */
    for (i = 0; i < framebuffer.nr_cbufs; i++) {
       assert(!framebuffer.cbufs[i] ||
              framebuffer.cbufs[i]->texture->bind & PIPE_BIND_RENDER_TARGET);
    }
    if (framebuffer.zsbuf) {
       assert(framebuffer.zsbuf->texture->bind & PIPE_BIND_DEPTH_STENCIL);
    }
 #endif
 
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 18d03cc4ada..7f2f1984e65 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -2189,21 +2189,21 @@ st_choose_format(struct st_context *st, GLenum internalFormat,
                  GLenum format, GLenum type,
                  enum pipe_texture_target target, unsigned sample_count,
                  unsigned storage_sample_count,
                  unsigned bindings, boolean allow_dxt)
 {
    struct pipe_screen *screen = st->pipe->screen;
    unsigned i;
    int j;
    enum pipe_format pf;
 
-#ifdef DEBUG
+#ifndef NDEBUG
    {
       static boolean firstCall = TRUE;
       if (firstCall) {
          test_format_conversion(st);
          firstCall = FALSE;
       }
    }
 #else
    (void) test_format_conversion;
 #endif
diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h
index 1170883f871..2624dcec0f2 100644
--- a/src/mesa/vbo/vbo_exec.h
+++ b/src/mesa/vbo/vbo_exec.h
@@ -104,21 +104,21 @@ struct vbo_exec_context
 
    struct {
       GLboolean recalculate_maps;
       struct vbo_exec_eval1_map map1[VERT_ATTRIB_MAX];
       struct vbo_exec_eval2_map map2[VERT_ATTRIB_MAX];
    } eval;
 
    /* Which flags to set in vbo_exec_begin_vertices() */
    GLbitfield begin_vertices_flags;
 
-#ifdef DEBUG
+#ifndef NDEBUG
    GLint flush_call_depth;
 #endif
 };
 
 
 
 void
 vbo_exec_init(struct gl_context *ctx);
 
 void
diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
index 5b1549d96de..bcab3f05342 100644
--- a/src/mesa/vbo/vbo_exec_api.c
+++ b/src/mesa/vbo/vbo_exec_api.c
@@ -1244,43 +1244,43 @@ vbo_exec_vtx_destroy(struct vbo_exec_context *exec)
  * Note that the default T&L engine never clears the
  * FLUSH_UPDATE_CURRENT bit, even after performing the update.
  *
  * \param flags  bitmask of FLUSH_STORED_VERTICES, FLUSH_UPDATE_CURRENT
  */
 void
 vbo_exec_FlushVertices(struct gl_context *ctx, GLuint flags)
 {
    struct vbo_exec_context *exec = &vbo_context(ctx)->exec;
 
-#ifdef DEBUG
+#ifndef NDEBUG
    /* debug check: make sure we don't get called recursively */
    exec->flush_call_depth++;
    assert(exec->flush_call_depth == 1);
 #endif
 
    if (_mesa_inside_begin_end(ctx)) {
       /* We've had glBegin but not glEnd! */
-#ifdef DEBUG
+#ifndef NDEBUG
       exec->flush_call_depth--;
       assert(exec->flush_call_depth == 0);
 #endif
       return;
    }
 
    /* Flush (draw), and make sure VBO is left unmapped when done */
    vbo_exec_FlushVertices_internal(exec, GL_TRUE);
 
    /* Need to do this to ensure vbo_exec_begin_vertices gets called again:
     */
    ctx->Driver.NeedFlush &= ~(FLUSH_UPDATE_CURRENT | flags);
 
-#ifdef DEBUG
+#ifndef NDEBUG
    exec->flush_call_depth--;
    assert(exec->flush_call_depth == 0);
 #endif
 }
 
 
 /**
  * Reset the vertex attribute by setting its size to zero.
  */
 static void
diff --git a/src/util/slab.c b/src/util/slab.c
index 5477c75d443..62634034fdc 100644
--- a/src/util/slab.c
+++ b/src/util/slab.c
@@ -24,41 +24,41 @@
 #include "slab.h"
 #include "macros.h"
 #include "u_atomic.h"
 #include <stdint.h>
 #include <stdbool.h>
 #include <string.h>
 
 #define SLAB_MAGIC_ALLOCATED 0xcafe4321
 #define SLAB_MAGIC_FREE 0x7ee01234
 
-#ifdef DEBUG
+#ifndef NDEBUG
 #define SET_MAGIC(element, value)   (element)->magic = (value)
 #define CHECK_MAGIC(element, value) assert((element)->magic == (value))
 #else
 #define SET_MAGIC(element, value)
 #define CHECK_MAGIC(element, value)
 #endif
 
 /* One array element within a big buffer. */
 struct slab_element_header {
    /* The next element in the free or migrated list. */
    struct slab_element_header *next;
 
    /* This is either
     * - a pointer to the child pool to which this element belongs, or
     * - a pointer to the orphaned page of the element, with the least
     *   significant bit set to 1.
     */
    intptr_t owner;
 
-#ifdef DEBUG
+#ifndef NDEBUG
    intptr_t magic;
 #endif
 };
 
 /* The page is an array of allocations in one block. */
 struct slab_page_header {
    union {
       /* Next page in the same child pool. */
       struct slab_page_header *next;
 
-- 
2.17.1



More information about the mesa-dev mailing list