stdafx.h
changeset 2639 eeaefdabfdfd
parent 2485 3e83ba6adf27
child 2694 9b5f6f369ab3
equal deleted inserted replaced
2638:0811adaec525 2639:eeaefdabfdfd
   196 # define TTD_ALIGNMENT_4
   196 # define TTD_ALIGNMENT_4
   197   static inline uint32 TO_LE32(uint32 x) { return BSWAP32(x); }
   197   static inline uint32 TO_LE32(uint32 x) { return BSWAP32(x); }
   198   static inline uint16 TO_LE16(uint16 x) { return BSWAP16(x); }
   198   static inline uint16 TO_LE16(uint16 x) { return BSWAP16(x); }
   199   static inline uint32 FROM_LE32(uint32 x) { return BSWAP32(x); }
   199   static inline uint32 FROM_LE32(uint32 x) { return BSWAP32(x); }
   200   static inline uint16 FROM_LE16(uint16 x) { return BSWAP16(x); }
   200   static inline uint16 FROM_LE16(uint16 x) { return BSWAP16(x); }
   201 # define TO_BE32(x) x
   201 # define TO_BE32(x) (x)
   202 # define TO_BE16(x) x
   202 # define TO_BE16(x) (x)
   203 # define FROM_BE32(x) x
   203 # define FROM_BE32(x) (x)
   204 # define FROM_BE16(x) x
   204 # define FROM_BE16(x) (x)
   205 # define TO_BE32X(x) x
   205 # define TO_BE32X(x) (x)
   206 #else
   206 #else
   207   static inline uint32 TO_BE32(uint32 x) { return BSWAP32(x); }
   207   static inline uint32 TO_BE32(uint32 x) { return BSWAP32(x); }
   208   static inline uint16 TO_BE16(uint16 x) { return BSWAP16(x); }
   208   static inline uint16 TO_BE16(uint16 x) { return BSWAP16(x); }
   209   static inline uint32 FROM_BE32(uint32 x) { return BSWAP32(x); }
   209   static inline uint32 FROM_BE32(uint32 x) { return BSWAP32(x); }
   210   static inline uint16 FROM_BE16(uint16 x) { return BSWAP16(x); }
   210   static inline uint16 FROM_BE16(uint16 x) { return BSWAP16(x); }
   211 # define TO_LE32(x) x
   211 # define TO_LE32(x) (x)
   212 # define TO_LE16(x) x
   212 # define TO_LE16(x) (x)
   213 # define TO_BE32X(x) BSWAP32(x)
   213 # define TO_BE32X(x) BSWAP32(x)
   214 # define FROM_LE32(x) x
   214 # define FROM_LE32(x) (x)
   215 # define FROM_LE16(x) x
   215 # define FROM_LE16(x) (x)
   216 #endif /* TTD_BIG_ENDIAN */
   216 #endif /* TTD_BIG_ENDIAN */
   217 
   217 
   218 #if !defined(GAME_DATA_DIR)
   218 #if !defined(GAME_DATA_DIR)
   219 # define GAME_DATA_DIR ""
   219 # define GAME_DATA_DIR ""
   220 #endif
   220 #endif
   239 # define assert_compile(expr) void __ct_assert__(int a[1 - 2 * !(expr)])
   239 # define assert_compile(expr) void __ct_assert__(int a[1 - 2 * !(expr)])
   240 #endif
   240 #endif
   241 
   241 
   242 assert_compile(sizeof(uint32) == 4);
   242 assert_compile(sizeof(uint32) == 4);
   243 assert_compile(sizeof(uint16) == 2);
   243 assert_compile(sizeof(uint16) == 2);
   244 assert_compile(sizeof(uint8)	== 1);
   244 assert_compile(sizeof(uint8)  == 1);
   245 
   245 
   246 #define lengthof(x) (sizeof(x)/sizeof(x[0]))
   246 #define lengthof(x) (sizeof(x)/sizeof(x[0]))
   247 #define endof(x) (&x[lengthof(x)])
   247 #define endof(x) (&x[lengthof(x)])
   248 #define lastof(x) (&x[lengthof(x) - 1])
   248 #define lastof(x) (&x[lengthof(x) - 1])
   249 #ifndef offsetof
   249 #ifndef offsetof