Change a few frequented uses of DEBUG to !NDEBUG

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.

Reviewed-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
This commit is contained in:
Marek Olšák
2019-05-09 21:04:23 -04:00
parent 0f1b68ebee
commit b5697c311b
18 changed files with 27 additions and 29 deletions

View File

@@ -1241,7 +1241,7 @@ static void validate( enum tgsi_opcode opcode,
unsigned nr_dst, unsigned nr_dst,
unsigned nr_src ) unsigned nr_src )
{ {
#ifdef DEBUG #ifndef NDEBUG
const struct tgsi_opcode_info *info = tgsi_get_opcode_info( opcode ); const struct tgsi_opcode_info *info = tgsi_get_opcode_info( opcode );
assert(info); assert(info);
if (info) { if (info) {

View File

@@ -953,7 +953,7 @@ static void si_bind_sampler_states(struct pipe_context *ctx,
sstates[i] == samplers->sampler_states[slot]) sstates[i] == samplers->sampler_states[slot])
continue; continue;
#ifdef DEBUG #ifndef NDEBUG
assert(sstates[i]->magic == SI_SAMPLER_STATE_MAGIC); assert(sstates[i]->magic == SI_SAMPLER_STATE_MAGIC);
#endif #endif
samplers->sampler_states[slot] = sstates[i]; samplers->sampler_states[slot] = sstates[i];

View File

@@ -607,7 +607,7 @@ struct si_sampler_view {
#define SI_SAMPLER_STATE_MAGIC 0x34f1c35a #define SI_SAMPLER_STATE_MAGIC 0x34f1c35a
struct si_sampler_state { struct si_sampler_state {
#ifdef DEBUG #ifndef NDEBUG
unsigned magic; unsigned magic;
#endif #endif
uint32_t val[4]; uint32_t val[4];

View File

@@ -651,7 +651,7 @@ static void emit_declaration(struct lp_build_tgsi_context *bld_base,
} }
if (!array_alloca) { if (!array_alloca) {
for (i = 0; i < decl_size; ++i) { for (i = 0; i < decl_size; ++i) {
#ifdef DEBUG #ifndef NDEBUG
snprintf(name, sizeof(name), "TEMP%d.%c", snprintf(name, sizeof(name), "TEMP%d.%c",
first + i / 4, "xyzw"[i % 4]); first + i / 4, "xyzw"[i % 4]);
#endif #endif
@@ -681,7 +681,7 @@ static void emit_declaration(struct lp_build_tgsi_context *bld_base,
for (i = 0; i < decl_size; ++i) { for (i = 0; i < decl_size; ++i) {
LLVMValueRef ptr; LLVMValueRef ptr;
if (writemask & (1 << (i % 4))) { if (writemask & (1 << (i % 4))) {
#ifdef DEBUG #ifndef NDEBUG
snprintf(name, sizeof(name), "TEMP%d.%c", snprintf(name, sizeof(name), "TEMP%d.%c",
first + i / 4, "xyzw"[i % 4]); first + i / 4, "xyzw"[i % 4]);
#endif #endif
@@ -735,7 +735,7 @@ static void emit_declaration(struct lp_build_tgsi_context *bld_base,
if (ctx->outputs[idx][0]) if (ctx->outputs[idx][0])
continue; continue;
for (chan = 0; chan < TGSI_NUM_CHANNELS; chan++) { for (chan = 0; chan < TGSI_NUM_CHANNELS; chan++) {
#ifdef DEBUG #ifndef NDEBUG
snprintf(name, sizeof(name), "OUT%d.%c", snprintf(name, sizeof(name), "OUT%d.%c",
idx, "xyzw"[chan % 4]); idx, "xyzw"[chan % 4]);
#endif #endif

View File

@@ -4328,7 +4328,7 @@ static void *si_create_sampler_state(struct pipe_context *ctx,
return NULL; return NULL;
} }
#ifdef DEBUG #ifndef NDEBUG
rstate->magic = SI_SAMPLER_STATE_MAGIC; rstate->magic = SI_SAMPLER_STATE_MAGIC;
#endif #endif
rstate->val[0] = (S_008F30_CLAMP_X(si_tex_wrap(state->wrap_s)) | rstate->val[0] = (S_008F30_CLAMP_X(si_tex_wrap(state->wrap_s)) |
@@ -4407,7 +4407,7 @@ static void si_emit_sample_mask(struct si_context *sctx)
static void si_delete_sampler_state(struct pipe_context *ctx, void *state) static void si_delete_sampler_state(struct pipe_context *ctx, void *state)
{ {
#ifdef DEBUG #ifndef NDEBUG
struct si_sampler_state *s = state; struct si_sampler_state *s = state;
assert(s->magic == SI_SAMPLER_STATE_MAGIC); assert(s->magic == SI_SAMPLER_STATE_MAGIC);

View File

@@ -939,7 +939,7 @@ nop_handler(const char *name)
if (ctx) { if (ctx) {
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid call)", name); _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid call)", name);
} }
#if defined(DEBUG) #ifndef NDEBUG
else if (getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")) { else if (getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")) {
fprintf(stderr, fprintf(stderr,
"GL User Error: gl%s called without a rendering context\n", "GL User Error: gl%s called without a rendering context\n",

View File

@@ -140,7 +140,7 @@ void _mesa_print_info( struct gl_context *ctx )
static void static void
set_verbose_flags(const char *str) set_verbose_flags(const char *str)
{ {
#ifdef DEBUG #ifndef NDEBUG
struct option { struct option {
const char *name; const char *name;
GLbitfield flag; GLbitfield flag;
@@ -181,7 +181,7 @@ set_verbose_flags(const char *str)
static void static void
set_debug_flags(const char *str) set_debug_flags(const char *str)
{ {
#ifdef DEBUG #ifndef NDEBUG
struct option { struct option {
const char *name; const char *name;
GLbitfield flag; GLbitfield flag;

View File

@@ -59,7 +59,7 @@ output_if_debug(const char *prefixString, const char *outputString,
LogFile = fopen(logFile, "w"); LogFile = fopen(logFile, "w");
if (!LogFile) if (!LogFile)
LogFile = stderr; LogFile = stderr;
#ifdef DEBUG #ifndef NDEBUG
/* in debug builds, print messages unless MESA_DEBUG="silent" */ /* in debug builds, print messages unless MESA_DEBUG="silent" */
if (MESA_DEBUG_FLAGS & DEBUG_SILENT) if (MESA_DEBUG_FLAGS & DEBUG_SILENT)
debug = 0; debug = 0;
@@ -189,7 +189,7 @@ should_output(struct gl_context *ctx, GLenum error, const char *fmtString)
if (debug == -1) { if (debug == -1) {
const char *debugEnv = getenv("MESA_DEBUG"); const char *debugEnv = getenv("MESA_DEBUG");
#ifdef DEBUG #ifndef NDEBUG
if (debugEnv && strstr(debugEnv, "silent")) if (debugEnv && strstr(debugEnv, "silent"))
debug = GL_FALSE; debug = GL_FALSE;
else else
@@ -378,7 +378,7 @@ _mesa_error_no_memory(const char *caller)
void void
_mesa_debug( const struct gl_context *ctx, const char *fmtString, ... ) _mesa_debug( const struct gl_context *ctx, const char *fmtString, ... )
{ {
#ifdef DEBUG #ifndef NDEBUG
char s[MAX_DEBUG_MESSAGE_LENGTH]; char s[MAX_DEBUG_MESSAGE_LENGTH];
va_list args; va_list args;
va_start(args, fmtString); va_start(args, fmtString);

View File

@@ -428,7 +428,7 @@ _mesa_RenderMode( GLenum mode )
} }
if (ctx->Select.BufferCount > ctx->Select.BufferSize) { if (ctx->Select.BufferCount > ctx->Select.BufferSize) {
/* overflow */ /* overflow */
#ifdef DEBUG #ifndef NDEBUG
_mesa_warning(ctx, "Feedback buffer overflow"); _mesa_warning(ctx, "Feedback buffer overflow");
#endif #endif
result = -1; result = -1;

View File

@@ -734,9 +734,7 @@ _mesa_get_uncompressed_format(mesa_format format)
case MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT: case MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT:
return MESA_FORMAT_RGB_FLOAT32; return MESA_FORMAT_RGB_FLOAT32;
default: default:
#ifdef DEBUG
assert(!_mesa_is_format_compressed(format)); assert(!_mesa_is_format_compressed(format));
#endif
return format; return format;
} }
} }

View File

@@ -102,7 +102,7 @@ _mesa_align_malloc(size_t bytes, unsigned long alignment)
buf = (ptr + alignment + sizeof(void *)) & ~(uintptr_t)(alignment - 1); buf = (ptr + alignment + sizeof(void *)) & ~(uintptr_t)(alignment - 1);
*(uintptr_t *)(buf - sizeof(void *)) = ptr; *(uintptr_t *)(buf - sizeof(void *)) = ptr;
#ifdef DEBUG #ifndef NDEBUG
/* mark the non-aligned area */ /* mark the non-aligned area */
while ( ptr < buf - sizeof(void *) ) { while ( ptr < buf - sizeof(void *) ) {
*(unsigned long *)ptr = 0xcdcdcdcd; *(unsigned long *)ptr = 0xcdcdcdcd;
@@ -151,7 +151,7 @@ _mesa_align_calloc(size_t bytes, unsigned long alignment)
buf = (ptr + alignment + sizeof(void *)) & ~(uintptr_t)(alignment - 1); buf = (ptr + alignment + sizeof(void *)) & ~(uintptr_t)(alignment - 1);
*(uintptr_t *)(buf - sizeof(void *)) = ptr; *(uintptr_t *)(buf - sizeof(void *)) = ptr;
#ifdef DEBUG #ifndef NDEBUG
/* mark the non-aligned area */ /* mark the non-aligned area */
while ( ptr < buf - sizeof(void *) ) { while ( ptr < buf - sizeof(void *) ) {
*(unsigned long *)ptr = 0xcdcdcdcd; *(unsigned long *)ptr = 0xcdcdcdcd;

View File

@@ -5172,7 +5172,7 @@ struct gl_memory_info
unsigned nr_device_memory_evictions; /**< # of evictions (monotonic counter) */ unsigned nr_device_memory_evictions; /**< # of evictions (monotonic counter) */
}; };
#ifdef DEBUG #ifndef NDEBUG
extern int MESA_VERBOSE; extern int MESA_VERBOSE;
extern int MESA_DEBUG_FLAGS; extern int MESA_DEBUG_FLAGS;
#else #else

View File

@@ -474,7 +474,7 @@ detach_shader(struct gl_context *ctx, GLuint program, GLuint shader,
shProg->Shaders = newList; shProg->Shaders = newList;
shProg->NumShaders = n - 1; shProg->NumShaders = n - 1;
#ifdef DEBUG #ifndef NDEBUG
/* sanity check - make sure the new list's entries are sensible */ /* sanity check - make sure the new list's entries are sensible */
for (j = 0; j < shProg->NumShaders; j++) { for (j = 0; j < shProg->NumShaders; j++) {
assert(shProg->Shaders[j]->Stage == MESA_SHADER_VERTEX || assert(shProg->Shaders[j]->Stage == MESA_SHADER_VERTEX ||

View File

@@ -188,7 +188,7 @@ st_update_framebuffer_state( struct st_context *st )
else else
framebuffer.zsbuf = NULL; framebuffer.zsbuf = NULL;
#ifdef DEBUG #ifndef NDEBUG
/* Make sure the resource binding flags were set properly */ /* Make sure the resource binding flags were set properly */
for (i = 0; i < framebuffer.nr_cbufs; i++) { for (i = 0; i < framebuffer.nr_cbufs; i++) {
assert(!framebuffer.cbufs[i] || assert(!framebuffer.cbufs[i] ||

View File

@@ -2196,7 +2196,7 @@ st_choose_format(struct st_context *st, GLenum internalFormat,
int j; int j;
enum pipe_format pf; enum pipe_format pf;
#ifdef DEBUG #ifndef NDEBUG
{ {
static boolean firstCall = TRUE; static boolean firstCall = TRUE;
if (firstCall) { if (firstCall) {

View File

@@ -111,7 +111,7 @@ struct vbo_exec_context
/* Which flags to set in vbo_exec_begin_vertices() */ /* Which flags to set in vbo_exec_begin_vertices() */
GLbitfield begin_vertices_flags; GLbitfield begin_vertices_flags;
#ifdef DEBUG #ifndef NDEBUG
GLint flush_call_depth; GLint flush_call_depth;
#endif #endif
}; };

View File

@@ -1251,7 +1251,7 @@ vbo_exec_FlushVertices(struct gl_context *ctx, GLuint flags)
{ {
struct vbo_exec_context *exec = &vbo_context(ctx)->exec; struct vbo_exec_context *exec = &vbo_context(ctx)->exec;
#ifdef DEBUG #ifndef NDEBUG
/* debug check: make sure we don't get called recursively */ /* debug check: make sure we don't get called recursively */
exec->flush_call_depth++; exec->flush_call_depth++;
assert(exec->flush_call_depth == 1); assert(exec->flush_call_depth == 1);
@@ -1259,7 +1259,7 @@ vbo_exec_FlushVertices(struct gl_context *ctx, GLuint flags)
if (_mesa_inside_begin_end(ctx)) { if (_mesa_inside_begin_end(ctx)) {
/* We've had glBegin but not glEnd! */ /* We've had glBegin but not glEnd! */
#ifdef DEBUG #ifndef NDEBUG
exec->flush_call_depth--; exec->flush_call_depth--;
assert(exec->flush_call_depth == 0); assert(exec->flush_call_depth == 0);
#endif #endif
@@ -1273,7 +1273,7 @@ vbo_exec_FlushVertices(struct gl_context *ctx, GLuint flags)
*/ */
ctx->Driver.NeedFlush &= ~(FLUSH_UPDATE_CURRENT | flags); ctx->Driver.NeedFlush &= ~(FLUSH_UPDATE_CURRENT | flags);
#ifdef DEBUG #ifndef NDEBUG
exec->flush_call_depth--; exec->flush_call_depth--;
assert(exec->flush_call_depth == 0); assert(exec->flush_call_depth == 0);
#endif #endif

View File

@@ -31,7 +31,7 @@
#define SLAB_MAGIC_ALLOCATED 0xcafe4321 #define SLAB_MAGIC_ALLOCATED 0xcafe4321
#define SLAB_MAGIC_FREE 0x7ee01234 #define SLAB_MAGIC_FREE 0x7ee01234
#ifdef DEBUG #ifndef NDEBUG
#define SET_MAGIC(element, value) (element)->magic = (value) #define SET_MAGIC(element, value) (element)->magic = (value)
#define CHECK_MAGIC(element, value) assert((element)->magic == (value)) #define CHECK_MAGIC(element, value) assert((element)->magic == (value))
#else #else
@@ -51,7 +51,7 @@ struct slab_element_header {
*/ */
intptr_t owner; intptr_t owner;
#ifdef DEBUG #ifndef NDEBUG
intptr_t magic; intptr_t magic;
#endif #endif
}; };