medfall

A super great game engine
Log | Files | Refs

commit 6a597e0bda9fcda1ee8b2097f1fca819651a8980
parent f280b5b3936c8122383b1fa90f49db4ec8e34266
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Tue May 16 03:50:30 +0300

Put ASSERT at the top of intrinsics.h

Diffstat:
intrinsics.h | 60++++++++++++++++++++++++++++++------------------------------
1 file changed, 30 insertions(+), 30 deletions(-)
diff --git a/intrinsics.h b/intrinsics.h @@ -36,6 +36,36 @@ typedef uintptr_t uptr; #define U32_MAX u32( UINT32_MAX ) #define U64_MAX u64( UINT64_MAX ) +#define STRINGIFY_HELPER( x ) #x +#define STRINGIFY( x ) STRINGIFY_HELPER( x ) + +#define CONCAT_HELPER( a, b ) a##b +#define CONCAT( a, b ) CONCAT_HELPER( a, b ) +#define COUNTER_NAME( x ) CONCAT( x, __COUNTER__ ) +#define LINE_NAME( x ) CONCAT( x, __LINE__ ) + +#if defined( assert ) +#undef assert +#endif + +inline void assert_impl( const bool predicate, const char * message ) { + if( !predicate ) { + puts( message ); + int err = errno; + printf( "errno(%d): %s\n", err, strerror( err ) ); + print_backtrace(); + abort(); + } +} + +#define ASSERT( predicate ) assert_impl( predicate, "\x1b[1;31massertion failed at " __FILE__ " line " STRINGIFY( __LINE__ ) ": \x1b[0;1m" #predicate "\x1b[0m" ) + +#if PLATFORM_CPP11 || COMPILER_MSVC +#define STATIC_ASSERT( p ) static_assert( p, #p ) +#else +#define STATIC_ASSERT( p ) static int COUNTER_NAME( STATIC_ASSERT_ )[ int( p ) - 1 ] +#endif + template< typename T, size_t N > char ( &ArrayCountObj( const T ( & )[ N ] ) )[ N ]; #define ARRAY_COUNT( arr ) ( sizeof( ArrayCountObj( arr ) ) ) @@ -97,28 +127,6 @@ inline T clamp11( T x ) { #define slots_required( data_size, slot_size ) ( ( data_size ) / ( slot_size ) + ( ( data_size ) % ( slot_size ) != 0 ) ) -#if defined( assert ) -#undef assert -#endif - -inline void assert_impl( const bool predicate, const char * message ) { - if( !predicate ) { - puts( message ); - int err = errno; - printf( "errno(%d): %s\n", err, strerror( err ) ); - print_backtrace(); - abort(); - } -} - -#define STRINGIFY_HELPER( x ) #x -#define STRINGIFY( x ) STRINGIFY_HELPER( x ) - -#define CONCAT_HELPER( a, b ) a##b -#define CONCAT( a, b ) CONCAT_HELPER( a, b ) -#define COUNTER_NAME( x ) CONCAT( x, __COUNTER__ ) -#define LINE_NAME( x ) CONCAT( x, __LINE__ ) - #define CACHE_LINE_SIZE 64 #define CACHE_LINE_PADDING u8 COUNTER_NAME( cache_line_spacing )[ CACHE_LINE_SIZE ] @@ -129,14 +137,6 @@ inline void assert_impl( const bool predicate, const char * message ) { } AtStartupInstance; \ } -#define ASSERT( predicate ) assert_impl( predicate, "\x1b[1;31massertion failed at " __FILE__ " line " STRINGIFY( __LINE__ ) ": \x1b[0;1m" #predicate "\x1b[0m" ) - -#if PLATFORM_CPP11 || COMPILER_MSVC -#define STATIC_ASSERT( p ) static_assert( p, #p ) -#else -#define STATIC_ASSERT( p ) static int COUNTER_NAME( STATIC_ASSERT_ )[ int( p ) - 1 ] -#endif - #if PLATFORM_CPP11 || COMPILER_MSVC #define NONCOPYABLE( T ) T( const T & ) = delete; void operator=( const T & ) = delete; #else