2023-09-09 20:14:40 -04:00
|
|
|
#pragma once
|
|
|
|
|
2023-09-08 21:08:57 -04:00
|
|
|
// Keywords
|
|
|
|
|
|
|
|
#define global static // Global variables
|
|
|
|
#define internal static // Internal linkage
|
|
|
|
#define local_persist static // Local Persisting variables
|
2023-09-09 00:01:53 -04:00
|
|
|
|
|
|
|
#define api_c extern "C"
|
2023-09-09 03:03:03 -04:00
|
|
|
|
|
|
|
// Casting
|
|
|
|
|
2023-09-30 10:05:37 -04:00
|
|
|
#define ccast( type, value ) ( const_cast< type >( (value) ) )
|
|
|
|
#define pcast( type, value ) ( * reinterpret_cast< type* >( & ( value ) ) )
|
|
|
|
#define rcast( type, value ) reinterpret_cast< type >( value )
|
|
|
|
#define scast( type, value ) static_cast< type >( value )
|
2023-09-09 23:58:28 -04:00
|
|
|
|
2023-10-11 17:52:13 -04:00
|
|
|
#define do_once() for ( local_persist b32 once = true; once; once = false )
|
2023-09-09 23:58:28 -04:00
|
|
|
|
|
|
|
#define do_once_start \
|
|
|
|
do \
|
|
|
|
{ \
|
2023-09-18 20:16:40 -04:00
|
|
|
local_persist \
|
2023-09-30 10:05:37 -04:00
|
|
|
bool done = false; \
|
|
|
|
if ( done ) \
|
2023-09-09 23:58:28 -04:00
|
|
|
break; \
|
2023-09-30 10:05:37 -04:00
|
|
|
done = true;
|
2023-09-09 23:58:28 -04:00
|
|
|
|
|
|
|
#define do_once_end \
|
|
|
|
} \
|
2023-09-17 21:20:11 -04:00
|
|
|
while(0);
|
|
|
|
|
|
|
|
#define array_count( array ) ( sizeof( array ) / sizeof( ( array )[0] ) )
|
2023-09-18 20:16:40 -04:00
|
|
|
|
|
|
|
// TODO(Ed) : Move to memory header eventually
|
|
|
|
#define kilobytes( x ) ( ( x ) * ( s64 )( 1024 ) )
|
|
|
|
#define megabytes( x ) ( kilobytes( x ) * ( s64 )( 1024 ) )
|
|
|
|
#define gigabytes( x ) ( megabytes( x ) * ( s64 )( 1024 ) )
|
|
|
|
#define terabytes( x ) ( gigabytes( x ) * ( s64 )( 1024 ) )
|
|
|
|
|
2023-12-30 15:25:58 -05:00
|
|
|
#define max( a, b ) ( (a > b) ? (a) : (b) )
|
|
|
|
#define min( a, b ) ( (a < b) ? (a) : (b) )
|
|
|
|
|
2023-09-18 20:16:40 -04:00
|
|
|
// TODO(Ed) : Move to debug header eventually
|
|
|
|
|
|
|
|
#if Build_Development
|
|
|
|
# define assert( expression ) \
|
2023-09-22 02:16:40 -04:00
|
|
|
if ( !( expression ) ) \
|
|
|
|
{ \
|
|
|
|
__debugbreak(); \
|
2023-09-18 20:16:40 -04:00
|
|
|
}
|
|
|
|
// platform::assertion_failure( __FILE__, __LINE__, #expression );
|
|
|
|
#else
|
|
|
|
# define assert( expression )
|
|
|
|
#endif
|
|
|
|
|
2023-09-26 17:26:35 -04:00
|
|
|
#ifdef COMPILER_CLANG
|
|
|
|
# define compiler_decorated_func_name __PRETTY_NAME__
|
|
|
|
#elif defined(COMPILER_MSVC)
|
|
|
|
# define compiler_decorated_func_name __FUNCDNAME__
|
|
|
|
#endif
|
|
|
|
|
2023-09-22 02:16:40 -04:00
|
|
|
#if Build_Development
|
2023-10-01 20:17:14 -04:00
|
|
|
# define congrats( message ) platform::impl_congrats( message )
|
|
|
|
# define ensure( condition, message ) platform::impl_ensure( condition, message )
|
|
|
|
# define fatal( message ) platform::impl_fatal( message )
|
2023-09-22 02:16:40 -04:00
|
|
|
#else
|
2023-10-01 20:17:14 -04:00
|
|
|
# define congrats( message )
|
2023-12-29 12:29:22 -05:00
|
|
|
# define ensure( condition, message ) true
|
2023-10-01 20:17:14 -04:00
|
|
|
# define fatal( message )
|
2023-09-22 02:16:40 -04:00
|
|
|
#endif
|