commit 51f98ee069c7a21843d66135d5b7a6bd05846d8c parent b2d833c18fa917f55c2988d45f16a27b342bf457 Author: Michael Savage <mikejsavage@gmail.com> Date: Sun Jan 15 12:12:11 +0200 assert -> ASSERT Diffstat:
gpubtt.cc | | | 4 | ++-- |
immediate.cc | | | 4 | ++-- |
intrinsics.h | | | 5 | ++--- |
nonblocking_fixed_spsc_queue.h | | | 4 | ++-- |
rng/rng_utils.h | | | 2 | +- |
shadow_map.cc | | | 2 | +- |
terrain_manager.cc | | | 12 | ++++++------ |
work_queue.cc | | | 2 | +- |
diff --git a/gpubtt.cc b/gpubtt.cc @@ -8,7 +8,7 @@ static u32 btt_count_leaves( const BTT * btt ) { if( btt->left ) { - assert( btt->right != NULL ); + ASSERT( btt->right != NULL ); return btt_count_leaves( btt->left ) + btt_count_leaves( btt->right ); } @@ -25,7 +25,7 @@ static void gpubtt_build( v2s32 mid = ( p0 + p2 ) / 2; gpubtt_build( verts, i, ohm, btt->left, p1, mid, p0 ); - assert( btt->right != NULL ); + ASSERT( btt->right != NULL ); gpubtt_build( verts, i, ohm, btt->right, p2, mid, p1 ); } else { diff --git a/immediate.cc b/immediate.cc @@ -13,7 +13,7 @@ void immediate_init( ImmediateContext * ctx, ImmediateTriangle * memory, size_t } void immediate_triangle( ImmediateContext * ctx, v3 p1, v3 p2, v3 p3, v4 colour ) { - assert( ctx->num_triangles < ctx->max_triangles - 1 ); + ASSERT( ctx->num_triangles < ctx->max_triangles - 1 ); v2 uv( 0, 0 ); ImmediateTriangle triangle = { { @@ -29,7 +29,7 @@ void immediate_triangle( ImmediateContext * ctx, ImmediateVertex v1, ImmediateVertex v2, ImmediateVertex v3 ) { - assert( ctx->num_triangles < ctx->max_triangles - 1 ); + ASSERT( ctx->num_triangles < ctx->max_triangles - 1 ); ImmediateTriangle triangle = { { v1, v2, v3 } }; diff --git a/intrinsics.h b/intrinsics.h @@ -103,7 +103,7 @@ inline T clamp11( T x ) { #undef assert #endif -inline void mike_assert( const bool predicate, const char * message ) { +inline void assert_impl( const bool predicate, const char * message ) { if( !predicate ) { puts( message ); int err = errno; @@ -125,8 +125,7 @@ inline void mike_assert( const bool predicate, const char * message ) { #define CONCAT_HELPER( a, b ) a##b #define CONCAT( a, b ) CONCAT_HELPER( a, b ) -#define assert( predicate ) mike_assert( predicate, "\x1b[1;31massertion failed at " __FILE__ " line " STRINGIFY( __LINE__ ) ": \x1b[0;1m" #predicate "\x1b[0m" ) -#define ASSERT assert +#define ASSERT( predicate ) assert_impl( predicate, "\x1b[1;31massertion failed at " __FILE__ " line " STRINGIFY( __LINE__ ) ": \x1b[0;1m" #predicate "\x1b[0m" ) #if COMPILER_MSVC || __cplusplus >= 201103L #define STATIC_ASSERT( p ) static_assert( p, #p ) diff --git a/nonblocking_fixed_spsc_queue.h b/nonblocking_fixed_spsc_queue.h @@ -29,7 +29,7 @@ public: // queue is empty // call dequeue_release once you're done with the pointer T * dequeue_acquire() { - assert( !VAR( reader_acquired ) ); + ASSERT( !VAR( reader_acquired ) ); size_t r = VAR( reader_pos ); if( load_acquire( &nodes[ r ].last_op ) == READ ) return NULL; @@ -39,7 +39,7 @@ public: } void dequeue_release() { - assert( VAR( reader_acquired ) ); + ASSERT( VAR( reader_acquired ) ); VAR( reader_acquired ) = false; size_t r = VAR( reader_pos ); diff --git a/rng/rng_utils.h b/rng/rng_utils.h @@ -64,7 +64,7 @@ u32 rng_uniform( T * rng, u32 upper_bound ) { // [min, max) template< typename T > u32 rng_uniform( T * rng, u32 lower_bound, u32 upper_bound ) { - assert( lower_bound <= upper_bound ); + ASSERT( lower_bound <= upper_bound ); return rng_uniform( rng, upper_bound - lower_bound ) + lower_bound; } diff --git a/shadow_map.cc b/shadow_map.cc @@ -119,7 +119,7 @@ extern "C" GAME_INIT( game_init ) { glDrawBuffer( GL_NONE ); glReadBuffer( GL_NONE ); - assert( glCheckFramebufferStatus( GL_FRAMEBUFFER ) == GL_FRAMEBUFFER_COMPLETE ); + ASSERT( glCheckFramebufferStatus( GL_FRAMEBUFFER ) == GL_FRAMEBUFFER_COMPLETE ); glBindFramebuffer( GL_FRAMEBUFFER, 0 ); diff --git a/terrain_manager.cc b/terrain_manager.cc @@ -248,7 +248,7 @@ void terrain_init( sprintf( dims_path, "%s/dims.txt", tiles_dir ); FILE * dims = fopen( dims_path, "r" ); - assert( dims != NULL ); + ASSERT( dims != NULL ); fscanf( dims, "%d %d", &tm->width, &tm->height ); fclose( dims ); @@ -303,7 +303,7 @@ void terrain_init( } void terrain_teleport( TerrainManager * tm, v3 position ) { - assert( tm->first_teleport ); + ASSERT( tm->first_teleport ); tm->first_teleport = false; @@ -466,10 +466,10 @@ void terrain_render( TerrainManager * tm, const m4 & V, const m4 & P, float sun, } float terrain_height( const TerrainManager * tm, v3 position ) { - assert( position.x >= 0 ); - assert( position.y >= 0 ); - assert( position.x < tm->width ); - assert( position.y < tm->height ); + ASSERT( position.x >= 0 ); + ASSERT( position.y >= 0 ); + ASSERT( position.x < tm->width ); + ASSERT( position.y < tm->height ); s32 tx = s32( position.x / TILE_SIZE ); s32 ty = s32( position.y / TILE_SIZE ); diff --git a/work_queue.cc b/work_queue.cc @@ -90,7 +90,7 @@ void workqueue_enqueue( WorkQueue * queue, WorkQueueCallback * callback, const v callback( data, &queue->arenas[ 0 ] ); #else u32 tail = fetch_add_release( &queue->tail, 1 ); - assert( tail - load_acquire( &queue->head ) < ARRAY_COUNT( queue->jobs ) - 1 ); + ASSERT( tail - load_acquire( &queue->head ) < ARRAY_COUNT( queue->jobs ) - 1 ); Job job = { callback, data };