forked from mirror/OpenTTD
(svn r3529) - Fix: [ 1415782 ] crash in string code with openbsd/zaurus; alignment issues (thanks Tron for the help)
This commit is contained in:
18
macros.h
18
macros.h
@@ -142,14 +142,20 @@ static inline void swap_int32(int32 *a, int32 *b) { int32 t = *a; *a = *b; *b =
|
||||
static inline void swap_tile(TileIndex *a, TileIndex *b) { TileIndex t = *a; *a = *b; *b = t; }
|
||||
|
||||
|
||||
static inline uint16 ReadLE16Aligned(const void* x)
|
||||
{
|
||||
return FROM_LE16(*(const uint16*)x);
|
||||
}
|
||||
|
||||
#if defined(TTD_LITTLE_ENDIAN)
|
||||
# define READ_LE_UINT16(b) (*(const uint16*)(b))
|
||||
#elif defined(TTD_BIG_ENDIAN)
|
||||
static inline uint16 READ_LE_UINT16(const void *b) {
|
||||
return ((const byte*)b)[0] + (((const byte*)b)[1] << 8);
|
||||
}
|
||||
static inline uint16 ReadLE16Unaligned(const void* x)
|
||||
{
|
||||
#ifdef OTTD_ALIGNMENT
|
||||
return ((const byte*)x)[0] | ((const byte*)x)[1] << 8;
|
||||
#else
|
||||
return FROM_LE16(*(const uint16*)x);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ROtate x Left/Right by n (must be >= 0)
|
||||
|
Reference in New Issue
Block a user