Changeset 560
- Timestamp:
- 04/11/08 11:59:37 (9 months ago)
- Files:
-
- branches/morph-targets/libx42/include/x42compilerutils.h (modified) (1 diff)
- branches/morph-targets/libx42/include/x42data.h (modified) (2 diffs)
- branches/morph-targets/libx42/local.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/morph-targets/libx42/include/x42compilerutils.h
r322 r560 24 24 #define INC_LIBX42_X42COMPILERUTILS_H 25 25 26 /* 27 Compiler helper macros (of doom!): 28 29 X42_CALL 30 Used in all exported functions to (optionally) force a 31 particular calling convention. 32 33 X42_EXPORT: 34 Marks all exported functions. May be useful to turn this 35 into a __declspec( dllexport ) (or equivalent) for DLL builds. 36 37 X42_NORETURN: 38 Marks functions that don't return anything. Set this to 39 __declspec( noreturn ) (or equivalent) to pass the hint 40 on to the compiler's optimizer. 41 42 X42_NODEFAULT: 43 Placed at the end of switch-case statements that will never hit 44 their default block. Used to pass compiler hints. 45 46 X42_PACKED: 47 Placed on certain structures in __attribute__(( packed )) position 48 to keep persisted data structures from being padded out on certain 49 systems. 50 */ 51 26 52 #ifdef __cplusplus_cli 27 #define X42_CALL __stdcall 28 #define X42_EXPORT 29 #elif defined( _WIN32 ) 30 #define X42_CALL __stdcall 31 #define X42_EXPORT 32 #else 33 #define X42_CALL 34 #define X42_EXPORT 53 54 #define X42_CALL __stdcall 55 #define X42_EXPORT 56 57 #elif /* __cplusplus_cli */ defined( _WIN32 ) 58 59 #define X42_CALL __stdcall 60 #define X42_EXPORT 61 62 #else /* _WIN32 */ 63 64 #define X42_CALL 65 #define X42_EXPORT 66 35 67 #endif 36 68 37 69 #ifdef _MSC_VER 38 #define X42_NORETURN __declspec( noreturn ) 39 #define X42_NODEFAULT default: __assume( 0 ); break 40 #else 41 #define X42_NORETURN 42 #define X42_NODEFAULT default: break 70 71 #define X42_NORETURN __declspec( noreturn ) 72 #define X42_NODEFAULT default: __assume( 0 ); break 73 74 #define X42_PACKED //MSVC does not require this, it already has the packing rules we want 75 76 #elif /* _MSC_VER */ defined( __GNUC__ ) 77 78 #define X42_NORETURN 79 #define X42_NODEFAULT default: break 80 81 #define X42_PACKED __attribute__(( packed )) 82 83 #else /* __GNUC__ */ 84 85 #define X42_NORETURN 86 #define X42_NODEFAULT default: break 87 88 #define X42_PACKED 89 43 90 #endif 44 91 branches/morph-targets/libx42/include/x42data.h
r501 r560 222 222 } x42Animation_v5_t; 223 223 224 typedef struct x42AnimGroup_v5_t224 typedef struct X42_PACKED x42AnimGroup_v5_t 225 225 { 226 226 x42NameIndex_t name; … … 341 341 } x42Group_v5_t; 342 342 343 typedef struct x42LodRange_v5_t343 typedef struct X42_PACKED x42LodRange_v5_t 344 344 { 345 345 u16 lodName; branches/morph-targets/libx42/local.h
r501 r560 25 25 26 26 #if _MSC_VER >= 1400 27 #define _CRT_SECURE_NO_DEPRECATE27 #define _CRT_SECURE_NO_DEPRECATE 28 28 #endif 29 29 … … 36 36 37 37 #ifdef LIBX42_NO_MATH_F 38 /* so far we just use sqrtf */39 #define sqrtf( x ) (float)sqrt( x )38 /* so far we just use sqrtf */ 39 #define sqrtf( x ) (float)sqrt( x ) 40 40 #endif 41 41 … … 44 44 #define X42_RF_LOAD_SWAPPED 0x0001 45 45 46 #ifdef __cplusplus 47 #define CONST_CAST( T, v ) const_cast< T* >( v ) 48 #else /* __cplusplus */ 49 #define CONST_CAST( T, v ) ((T*)(v)) 50 #endif 51 46 52 #ifdef _MSC_VER 47 53 48 #define INLINE static __inline49 #define ALWAYS_INLINE static __forceinline50 #define REF_PARAM( x ) (void)sizeof( x )54 #define INLINE static __inline 55 #define ALWAYS_INLINE static __forceinline 56 #define REF_PARAM( x ) (void)sizeof( x ) 51 57 52 #ifdef __cplusplus 53 #define CONST_CAST( T, v ) const_cast< T* >( v ) 54 #else 55 #define CONST_CAST( T, v ) ((T*)(v)) 56 #endif 58 #if _MSC_VER >= 1400 59 #define RESTRICT __restrict 60 #define NOGLOBALALIAS __declspec( noalias ) 61 #else /* _MSC_VER >= 1400 */ 62 #define RESTRICT 63 #define NOGLOBALALIAS 64 #endif 57 65 58 #if _MSC_VER >= 1400 59 #define RESTRICT __restrict 60 #define NOGLOBALALIAS __declspec( noalias ) 61 #else 62 #define RESTRICT 63 #define NOGLOBALALIAS 64 #endif 66 #define NO_DEFAULT default: __assume( 0 ); break; 65 67 66 # define NO_DEFAULT default: __assume( 0 ); break;68 #elif /* _MSC_VER */ defined( __GNUC__ ) 67 69 68 #else 69 #define INLINE static 70 #define ALWAYS_INLINE static 70 #define INLINE static 71 #define ALWAYS_INLINE static 71 72 72 #define REF_PARAM( x ) (x) = (x)73 #define REF_PARAM( x ) (x) = (x) 73 74 74 #define RESTRICT 75 #define NOGLOBALALIAS75 #define RESTRICT __restrict 76 #define NOGLOBALALIAS 76 77 77 #define NO_DEFAULT default: break; 78 #define NO_DEFAULT default: break; 79 #include <alloca.h> 80 #define _alloca alloca 81 82 //intptr_t is not defined where I 83 //think it is defined under GCC 84 #include <stdint.h> 85 86 #else /* __GNUC__ */ 87 88 #define INLINE static 89 #define ALWAYS_INLINE static 90 91 #define REF_PARAM( x ) (x) = (x) 92 93 #define RESTRICT 94 #define NOGLOBALALIAS 95 96 #define NO_DEFAULT default: break; 97 78 98 #endif 79 99 … … 137 157 138 158 #ifdef DEBUG 139 #ifdef _MSC_VER140 #define debugger_break() __debugbreak()141 #else142 #define debugger_break() *(int*)0 = 1 /* force a crash! */143 #endif144 159 145 #define assert( cond, code, msg ) if( !(cond) ) { LIBX42_ERROR_EVENT( code, msg ); debugger_break(); } else (void)0 146 #else 147 #define assert( cond, code, msg ) if( const_cond_true ) { (void)sizeof( cond ); } else (void)0 160 #ifdef _MSC_VER 161 #define debugger_break() __debugbreak() 162 #else /* _MSC_VER */ 163 #define debugger_break() *(int*)0 = 1 /* force a crash! */ 164 #endif /* !_MSC_VER */ 165 166 #define assert( cond, code, msg ) if( !(cond) ) { LIBX42_ERROR_EVENT( code, msg ); debugger_break(); } else (void)0 167 168 #else /* DEBUG */ 169 170 #define assert( cond, code, msg ) if( const_cond_true ) { (void)sizeof( cond ); } else (void)0 171 148 172 #endif 149 173
