From 5a2e08c58a81488de3dd5c7397d0f8ae7a2ad36c Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 13 Jan 2010 07:25:28 +0000 Subject: [PATCH] The config sets the default assertion level so people can override it for their own use in application code. --- configure.in | 8 ++++---- include/SDL.h | 1 - include/SDL_assert.h | 11 ++++------- include/SDL_config.h.in | 2 +- include/SDL_config_iphoneos.h | 2 +- include/SDL_config_macosx.h | 2 +- include/SDL_config_minimal.h | 2 +- include/SDL_config_nintendods.h | 2 +- include/SDL_config_pandora.h | 2 +- include/SDL_config_win32.h | 2 +- include/SDL_config_wiz.h | 2 +- 11 files changed, 16 insertions(+), 20 deletions(-) diff --git a/configure.in b/configure.in index cb3b6ce75..83bbd375c 100644 --- a/configure.in +++ b/configure.in @@ -142,19 +142,19 @@ AC_HELP_STRING([--enable-assertions], sdl_valid_assertion_level=no if test x$enable_assertions = xno; then sdl_valid_assertion_level=yes - AC_DEFINE(SDL_ASSERT_LEVEL, 0) + AC_DEFINE(SDL_DEFAULT_ASSERT_LEVEL, 0) fi if test x$enable_assertions = xrelease; then sdl_valid_assertion_level=yes - AC_DEFINE(SDL_ASSERT_LEVEL, 1) + AC_DEFINE(SDL_DEFAULT_ASSERT_LEVEL, 1) fi if test x$enable_assertions = xyes; then sdl_valid_assertion_level=yes - AC_DEFINE(SDL_ASSERT_LEVEL, 2) + AC_DEFINE(SDL_DEFAULT_ASSERT_LEVEL, 2) fi if test x$enable_assertions = xparanoid; then sdl_valid_assertion_level=yes - AC_DEFINE(SDL_ASSERT_LEVEL, 3) + AC_DEFINE(SDL_DEFAULT_ASSERT_LEVEL, 3) fi if test x$sdl_valid_assertion_level = xno; then AC_MSG_ERROR([*** unknown assertion level. stop.]) diff --git a/include/SDL.h b/include/SDL.h index 9831e831b..fc3110e89 100644 --- a/include/SDL.h +++ b/include/SDL.h @@ -77,7 +77,6 @@ #include "SDL_main.h" #include "SDL_stdinc.h" -#include "SDL_assert.h" #include "SDL_atomic.h" #include "SDL_audio.h" #include "SDL_cpuinfo.h" diff --git a/include/SDL_assert.h b/include/SDL_assert.h index 0bc03186e..3817fcfb4 100644 --- a/include/SDL_assert.h +++ b/include/SDL_assert.h @@ -21,13 +21,11 @@ */ #include "SDL_config.h" -/* This is an assert macro for SDL's internal use. Not for the public API! */ - #ifndef _SDL_assert_h #define _SDL_assert_h #ifndef SDL_ASSERT_LEVEL -#error SDL_ASSERT_LEVEL is not defined. Please fix your SDL_config.h. +#define SDL_ASSERT_LEVEL SDL_DEFAULT_ASSERT_LEVEL #endif /* @@ -107,12 +105,12 @@ SDL_assert_state SDL_ReportAssertion(SDL_assert_data *, const char *, int); #define SDL_enabled_assert(condition) \ do { \ while ( !(condition) ) { \ - static struct SDL_assert_data assert_data = { \ + static struct SDL_assert_data assert_data = { \ 0, 0, #condition, __FILE__, 0, 0, 0 \ }; \ - const SDL_assert_state state = SDL_ReportAssertion(&assert_data, \ + const SDL_assert_state state = SDL_ReportAssertion(&assert_data, \ SDL_FUNCTION, \ - __LINE__); \ + __LINE__); \ if (state == SDL_ASSERTION_RETRY) { \ continue; /* go again. */ \ } else if (state == SDL_ASSERTION_BREAK) { \ @@ -148,4 +146,3 @@ SDL_assert_state SDL_ReportAssertion(SDL_assert_data *, const char *, int); #endif /* _SDL_assert_h */ /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index f5e6f40b6..310b166e9 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -163,7 +163,7 @@ #endif /* HAVE_LIBC */ /* SDL internal assertion support */ -#undef SDL_ASSERT_LEVEL +#undef SDL_DEFAULT_ASSERT_LEVEL /* Allow disabling of core subsystems */ #undef SDL_AUDIO_DISABLED diff --git a/include/SDL_config_iphoneos.h b/include/SDL_config_iphoneos.h index 66b2bd437..288b18c8e 100644 --- a/include/SDL_config_iphoneos.h +++ b/include/SDL_config_iphoneos.h @@ -26,7 +26,7 @@ #include "SDL_platform.h" /* SDL internal assertion support */ -#define SDL_ASSERT_LEVEL 1 +#define SDL_DEFAULT_ASSERT_LEVEL 1 #if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) typedef signed char int8_t; diff --git a/include/SDL_config_macosx.h b/include/SDL_config_macosx.h index 66733b0d0..194cbc830 100644 --- a/include/SDL_config_macosx.h +++ b/include/SDL_config_macosx.h @@ -29,7 +29,7 @@ #include /* SDL internal assertion support */ -#define SDL_ASSERT_LEVEL 1 +#define SDL_DEFAULT_ASSERT_LEVEL 1 /* This is a set of defines to configure the SDL features */ diff --git a/include/SDL_config_minimal.h b/include/SDL_config_minimal.h index 6fc0829fc..9e5d43136 100644 --- a/include/SDL_config_minimal.h +++ b/include/SDL_config_minimal.h @@ -34,7 +34,7 @@ #include /* SDL internal assertion support */ -#define SDL_ASSERT_LEVEL 1 +#define SDL_DEFAULT_ASSERT_LEVEL 1 #if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) typedef signed char int8_t; diff --git a/include/SDL_config_nintendods.h b/include/SDL_config_nintendods.h index 9e3ea314f..a6bc07a61 100644 --- a/include/SDL_config_nintendods.h +++ b/include/SDL_config_nintendods.h @@ -28,7 +28,7 @@ /* This is a set of defines to configure the SDL features */ /* SDL internal assertion support */ -#define SDL_ASSERT_LEVEL 1 +#define SDL_DEFAULT_ASSERT_LEVEL 1 #if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) typedef signed char int8_t; diff --git a/include/SDL_config_pandora.h b/include/SDL_config_pandora.h index 58d1aec54..88440d69e 100644 --- a/include/SDL_config_pandora.h +++ b/include/SDL_config_pandora.h @@ -29,7 +29,7 @@ #include "SDL_platform.h" /* SDL internal assertion support */ -#define SDL_ASSERT_LEVEL 1 +#define SDL_DEFAULT_ASSERT_LEVEL 1 #define SDL_HAS_64BIT_TYPE 1 #define SDL_BYTEORDER 1234 diff --git a/include/SDL_config_win32.h b/include/SDL_config_win32.h index 3b23364f6..143371aa3 100644 --- a/include/SDL_config_win32.h +++ b/include/SDL_config_win32.h @@ -28,7 +28,7 @@ /* This is a set of defines to configure the SDL features */ /* SDL internal assertion support */ -#define SDL_ASSERT_LEVEL 1 +#define SDL_DEFAULT_ASSERT_LEVEL 1 #if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) #if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) diff --git a/include/SDL_config_wiz.h b/include/SDL_config_wiz.h index fc28afed5..e0b35d87f 100644 --- a/include/SDL_config_wiz.h +++ b/include/SDL_config_wiz.h @@ -29,7 +29,7 @@ #include "SDL_platform.h" /* SDL internal assertion support */ -#define SDL_ASSERT_LEVEL 1 +#define SDL_DEFAULT_ASSERT_LEVEL 1 /* Make sure that this isn't included by Visual C++ */ #ifdef _MSC_VER