annotate include/SDL_assert.h @ 3647:c5925cd41955

First pass at Ryan's assertion code, minor tweaks to come.
author Sam Lantinga <slouken@libsdl.org>
date Wed, 13 Jan 2010 06:47:17 +0000
parents
children 1e74d7984d0b
rev   line source
3647
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 Copyright (C) 1997-2009 Sam Lantinga
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Lesser General Public License for more details.
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 #include "SDL_config.h"
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 /* This is an assert macro for SDL's internal use. Not for the public API! */
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 #ifndef _SDL_assert_h
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27 #define _SDL_assert_h
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 #ifndef SDL_ASSERT_LEVEL
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 #error SDL_ASSERT_LEVEL is not defined. Please fix your SDL_config.h.
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 #endif
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 /*
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 sizeof (x) makes the compiler still parse the expression even without
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 assertions enabled, so the code is always checked at compile time, but
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 doesn't actually generate code for it, so there are no side effects or
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 expensive checks at run time, just the constant size of what x WOULD be,
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 which presumably gets optimized out as unused.
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 This also solves the problem of...
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 int somevalue = blah();
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 SDL_assert(somevalue == 1);
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 ...which would cause compiles to complain that somevalue is unused if we
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 disable assertions.
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 */
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 #define SDL_disabled_assert(condition) \
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 do { (void) sizeof ((condition)); } while (0)
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 #if (SDL_ASSERT_LEVEL > 0)
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 /*
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 These are macros and not first class functions so that the debugger breaks
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 on the assertion line and not in some random guts of SDL, and so each
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 macro can have unique static variables associated with it.
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 */
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 #if (defined(_MSC_VER) && ((_M_IX86) || (_M_X64)))
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 #define SDL_TriggerBreakpoint() __asm { int 3 }
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 #elif (defined(__GNUC__) && ((__i386__) || (__x86_64__)))
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" )
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 #elif defined(unix)
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 #include <signal.h>
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 #define SDL_TriggerBreakpoint() raise(SIGTRAP)
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 #else
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 #error Please define your platform or set SDL_ASSERT_LEVEL to 0.
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 #endif
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 #if (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 # define SDL_FUNCTION __func__
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 #elif ((__GNUC__ >= 2) || defined(_MSC_VER))
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 # define SDL_FUNCTION __FUNCTION__
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 #else
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 # define SDL_FUNCTION "???"
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 #endif
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 typedef enum
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 {
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 SDL_ASSERTION_RETRY, /**< Retry the assert immediately. */
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 SDL_ASSERTION_BREAK, /**< Make the debugger trigger a breakpoint. */
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 SDL_ASSERTION_ABORT, /**< Terminate the program. */
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 SDL_ASSERTION_IGNORE, /**< Ignore the assert. */
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 SDL_ASSERTION_ALWAYS_IGNORE, /**< Ignore the assert from now on. */
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 } SDL_assert_state;
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 typedef struct SDL_assert_data
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 {
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 int always_ignore;
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 unsigned int trigger_count;
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 const char *condition;
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 const char *filename;
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 int linenum;
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 const char *function;
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 struct SDL_assert_data *next;
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 } SDL_assert_data;
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 SDL_assert_state SDL_ReportAssertion(SDL_assert_data *, const char *, int);
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 /* the do {} while(0) avoids dangling else problems:
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 if (x) SDL_assert(y); else blah();
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 ... without the do/while, the "else" could attach to this macro's "if".
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 We try to handle just the minimum we need here in a macro...the loop,
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 the static vars, and break points. The heavy lifting is handled in
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 SDL_ReportAssertion(), in SDL_assert.c.
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 */
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 #define SDL_enabled_assert(condition) \
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 do { \
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 while ( !(condition) ) { \
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 static struct SDL_assert_data assert_data = { \
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 0, 0, #condition, __FILE__, 0, 0, 0 \
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 }; \
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 const SDL_assert_state state = SDL_ReportAssertion(&assert_data, \
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 SDL_FUNCTION, \
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 __LINE__); \
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 if (state == SDL_ASSERTION_RETRY) { \
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 continue; /* go again. */ \
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 } else if (state == SDL_ASSERTION_BREAK) { \
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 SDL_TriggerBreakpoint(); \
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 } \
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 break; /* not retrying. */ \
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 } \
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 } while (0)
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 #endif /* enabled assertions support code */
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 /* Enable various levels of assertions. */
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 #if SDL_ASSERT_LEVEL == 0 /* assertions disabled */
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 # define SDL_assert(condition) SDL_disabled_assert(condition)
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 # define SDL_assert_release(condition) SDL_disabled_assert(condition)
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 # define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 #elif SDL_ASSERT_LEVEL == 1 /* release settings. */
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 # define SDL_assert(condition) SDL_enabled_assert(condition)
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 # define SDL_assert_release(condition) SDL_enabled_assert(condition)
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 # define SDL_assert_paranoid(condition) SDL_enabled_assert(condition)
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 #elif SDL_ASSERT_LEVEL == 2 /* normal settings. */
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 # define SDL_assert(condition) SDL_enabled_assert(condition)
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 # define SDL_assert_release(condition) SDL_enabled_assert(condition)
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 # define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 #elif SDL_ASSERT_LEVEL == 3 /* paranoid settings. */
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 # define SDL_assert(condition) SDL_enabled_assert(condition)
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 # define SDL_assert_release(condition) SDL_enabled_assert(condition)
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 # define SDL_assert_paranoid(condition) SDL_enabled_assert(condition)
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 #else
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 # error Unknown assertion level. Please fix your SDL_config.h.
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 #endif
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 #endif /* _SDL_assert_h */
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 /* vi: set ts=4 sw=4 expandtab: */
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151