macros.h
changeset 2966 7f382cfeb93d
parent 2952 6a26eeda9679
child 3132 724ede39bda9
equal deleted inserted replaced
2965:edaa999a25dd 2966:7f382cfeb93d
   140 static inline void swap_int16(int16 *a, int16 *b) { int16 t = *a; *a = *b; *b = t; }
   140 static inline void swap_int16(int16 *a, int16 *b) { int16 t = *a; *a = *b; *b = t; }
   141 static inline void swap_int32(int32 *a, int32 *b) { int32 t = *a; *a = *b; *b = t; }
   141 static inline void swap_int32(int32 *a, int32 *b) { int32 t = *a; *a = *b; *b = t; }
   142 static inline void swap_tile(TileIndex *a, TileIndex *b) { TileIndex t = *a; *a = *b; *b = t; }
   142 static inline void swap_tile(TileIndex *a, TileIndex *b) { TileIndex t = *a; *a = *b; *b = t; }
   143 
   143 
   144 
   144 
       
   145 static inline uint16 ReadLE16Aligned(const void* x)
       
   146 {
       
   147 	return FROM_LE16(*(const uint16*)x);
       
   148 }
   145 
   149 
   146 #if defined(TTD_LITTLE_ENDIAN)
   150 static inline uint16 ReadLE16Unaligned(const void* x)
   147 #	define READ_LE_UINT16(b) (*(const uint16*)(b))
   151 {
   148 #elif defined(TTD_BIG_ENDIAN)
   152 #ifdef OTTD_ALIGNMENT
   149 	static inline uint16 READ_LE_UINT16(const void *b) {
   153 	return ((const byte*)x)[0] | ((const byte*)x)[1] << 8;
   150 		return ((const byte*)b)[0] + (((const byte*)b)[1] << 8);
   154 #else
   151 	}
   155 	return FROM_LE16(*(const uint16*)x);
   152 #endif
   156 #endif
       
   157 }
       
   158 
   153 
   159 
   154 /**
   160 /**
   155  * ROtate x Left/Right by n (must be >= 0)
   161  * ROtate x Left/Right by n (must be >= 0)
   156  * @note Assumes a byte has 8 bits
   162  * @note Assumes a byte has 8 bits
   157  */
   163  */