medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 12c41a9a137bb6c1015c0dbf91cf438c6f976d05
parent cc37839dccf8dfa44136c5087369aecb1cbb41a9
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sat Mar 11 10:49:35 +0200

Some platform cleanup

Diffstat:
intrinsics.h | 22+++++++++-------------
platform.h | 7+++++++
2 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/intrinsics.h b/intrinsics.h @@ -105,14 +105,7 @@ inline void assert_impl( const bool predicate, const char * message ) { puts( message ); int err = errno; printf( "errno(%d): %s\n", err, strerror( err ) ); - // TODO -#if defined( __GNUC__ ) - __builtin_trap(); -#elif defined( _MSC_VER ) - *( int * ) 0 = 0; -#else -#error new platform -#endif + abort(); } } @@ -136,15 +129,16 @@ inline void assert_impl( const bool predicate, const char * message ) { #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 +#if PLATFORM_CPP11 || COMPILER_MSVC #define STATIC_ASSERT( p ) static_assert( p, #p ) -#elif __cplusplus < 201103L +#else #define STATIC_ASSERT( p ) static int COUNTER_NAME( STATIC_ASSERT_ )[ int( p ) - 1 ] #endif -#if !PLATFORM_RELACY +#if PLATFORM_CPP11 || COMPILER_MSVC #define NONCOPYABLE( T ) T( const T & ) = delete; void operator=( const T & ) = delete; #else +// only used for relacy builds so we don't care too much #define NONCOPYABLE( T ) #endif @@ -181,12 +175,14 @@ inline To checked_cast( const From & from ) { template< typename T > inline bool is_aligned( const T * ptr ) { -#if COMPILER_MSVC +#if PLATFORM_CPP11 + return checked_cast< size_t >( ptr ) % alignof( T ) == 0; +#elif COMPILER_MSVC return checked_cast< size_t >( ptr ) % __alignof( T ) == 0; #elif PLATFORM_RELACY return checked_cast< size_t >( ptr ) % __alignof__( T ) == 0; #else - return checked_cast< size_t >( ptr ) % alignof( T ) == 0; +#error new platform #endif } diff --git a/platform.h b/platform.h @@ -17,6 +17,9 @@ #if defined( _MSC_VER ) # define COMPILER_MSVC 1 +# if _MSC_VER == 1800 +# define MSVC_VERSION 2013 +# endif #elif defined( __clang__ ) # define COMPILER_CLANG 1 # define COMPILER_GCCORCLANG 1 @@ -34,3 +37,7 @@ #ifdef RL_TEST # define PLATFORM_RELACY 1 #endif + +#if __cplusplus >= 201103L +# define PLATFORM_CPP11 1 +#endif