Changeset 560

Show
Ignore:
Timestamp:
04/11/08 11:59:37 (9 months ago)
Author:
phill
Message:

o Platform madness.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/morph-targets/libx42/include/x42compilerutils.h

    r322 r560  
    2424#define INC_LIBX42_X42COMPILERUTILS_H 
    2525 
     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 
    2652#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 
    3567#endif 
    3668 
    3769#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 
    4390#endif 
    4491 
  • branches/morph-targets/libx42/include/x42data.h

    r501 r560  
    222222} x42Animation_v5_t; 
    223223 
    224 typedef struct x42AnimGroup_v5_t 
     224typedef struct X42_PACKED x42AnimGroup_v5_t 
    225225{ 
    226226        x42NameIndex_t  name; 
     
    341341} x42Group_v5_t; 
    342342 
    343 typedef struct x42LodRange_v5_t 
     343typedef struct X42_PACKED x42LodRange_v5_t 
    344344{ 
    345345        u16                             lodName; 
  • branches/morph-targets/libx42/local.h

    r501 r560  
    2525 
    2626#if _MSC_VER >= 1400 
    27 #define _CRT_SECURE_NO_DEPRECATE 
     27       #define _CRT_SECURE_NO_DEPRECATE 
    2828#endif 
    2929 
     
    3636 
    3737#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 ) 
    4040#endif 
    4141 
     
    4444#define X42_RF_LOAD_SWAPPED                     0x0001 
    4545 
     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 
    4652#ifdef _MSC_VER 
    4753 
    48 #define INLINE static __inline 
    49 #define ALWAYS_INLINE static __forceinline 
    50 #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 ) 
    5157 
    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 
    5765 
    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; 
    6567 
    66 #define NO_DEFAULT default: __assume( 0 ); break; 
     68#elif /* _MSC_VER */ defined( __GNUC__ ) 
    6769 
    68 #else 
    69 #define INLINE static 
    70 #define ALWAYS_INLINE static 
     70        #define INLINE static 
     71        #define ALWAYS_INLINE static 
    7172 
    72 #define REF_PARAM( x ) (x) = (x) 
     73       #define REF_PARAM( x ) (x) = (x) 
    7374 
    74 #define RESTRICT 
    75 #define NOGLOBALALIAS 
     75        #define RESTRICT __restrict 
     76       #define NOGLOBALALIAS 
    7677 
    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 
    7898#endif 
    7999 
     
    137157 
    138158#ifdef DEBUG 
    139 #ifdef _MSC_VER 
    140 #define debugger_break() __debugbreak() 
    141 #else 
    142 #define debugger_break() *(int*)0 = 1 /* force a crash! */ 
    143 #endif 
    144159 
    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 
    148172#endif 
    149173