medfall

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

commit 411be66f719b4893e81814eb3b1a6d6e0e653906
parent 5fb287271076500098423d52f8625f8cf490975e
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sat Apr 16 14:28:22 +0100

Replace ifdefs with if defined( ... ) and add #error elses

Diffstat:
intrinsics.h | 2+-
platform_semaphore.h | 8++++----
platform_thread.h | 2++
stream.h | 8++++++--
unix_thread.h | 8++++----
5 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/intrinsics.h b/intrinsics.h @@ -60,7 +60,7 @@ T abs( T x ) { #include "platform_backtrace.h" -#ifdef assert +#if defined( assert ) #undef assert #endif diff --git a/platform_semaphore.h b/platform_semaphore.h @@ -2,12 +2,12 @@ #ifndef _PLATFORM_SEMAPHORE_H_ #define _PLATFORM_SEMAPHORE_H_ -#ifdef __linux__ +#if defined( __linux__ ) #include "linux_semaphore.h" -#endif - -#ifdef __APPLE__ +#elif defined( __APPLE__ ) #include "darwin_semaphore.h" +#else +#error new platform #endif #endif // _PLATFORM_SEMAPHORE_H_ diff --git a/platform_thread.h b/platform_thread.h @@ -3,6 +3,8 @@ #if defined( __linux__ ) || defined( __APPLE__ ) #include "unix_thread.h" +#else +#error new platform #endif #endif // _PLATFORM_THREAD_H_ diff --git a/stream.h b/stream.h @@ -7,7 +7,8 @@ struct Stream { char * ptr; }; -#ifdef IS_LITTLE_ENDIAN +#if defined( IS_LITTLE_ENDIAN ) + #define DEF_READ_WRITE( type ) \ inline Stream read_##type( Stream stream, type * v ) { \ *v = *( type * ) stream.ptr; \ @@ -19,7 +20,9 @@ struct Stream { stream.ptr += sizeof( type ); \ return stream; \ } -#else + +#elif defined( IS_BIG_ENDIAN ) + #define DEF_READ_WRITE( type ) \ inline Stream read_##type( Stream stream, type * v ) { \ char swapped[ sizeof( type ) ]; \ @@ -38,6 +41,7 @@ struct Stream { stream.ptr += sizeof( type ); \ return stream; \ } + #endif DEF_READ_WRITE( u8 ) diff --git a/unix_thread.h b/unix_thread.h @@ -23,12 +23,12 @@ inline void thread_init( Thread * thread, ThreadCallback callback, void * data ) } inline u32 thread_getid() { -#ifdef __linux__ +#if defined( __linux__ ) return syscall( SYS_gettid ); -#endif - -#ifdef __OpenBSD__ +#elif defined( __OpenBSD__ ) return getthrid(); +#else +#error new platform #endif }