diff --git a/src/core/bitmath_func.hpp b/src/core/bitmath_func.hpp index fdcb310b06..a40c7dba6e 100644 --- a/src/core/bitmath_func.hpp +++ b/src/core/bitmath_func.hpp @@ -365,7 +365,7 @@ static inline T ROR(const T x, const uint8 n) * (since it will use hardware swapping if available). * Even though they should return uint16 and uint32, we get * warnings if we don't cast those (why?) */ - #define BSWAP64(x) ((uint32)CFSwapInt64(x)) + #define BSWAP64(x) ((uint64)CFSwapInt64(x)) #define BSWAP32(x) ((uint32)CFSwapInt32(x)) #define BSWAP16(x) ((uint16)CFSwapInt16(x)) #elif defined(_MSC_VER) diff --git a/src/stdafx.h b/src/stdafx.h index af7d41c6fe..7a75db893c 100644 --- a/src/stdafx.h +++ b/src/stdafx.h @@ -419,6 +419,16 @@ assert_compile(SIZE_MAX >= UINT32_MAX); #define unlikely(x) (x) #endif /* __GNUC__ || __clang__ */ +#if defined(__GNUC__) || defined(__clang__) +__attribute__((aligned(1))) typedef uint16 unaligned_uint16; +__attribute__((aligned(1))) typedef uint32 unaligned_uint32; +__attribute__((aligned(1))) typedef uint64 unaligned_uint64; +#else +typedef uint16 unaligned_uint16; +typedef uint32 unaligned_uint32; +typedef uint64 unaligned_uint64; +#endif /* __GNUC__ || __clang__ */ + void NORETURN CDECL usererror(const char *str, ...) WARN_FORMAT(1, 2); void NORETURN CDECL error(const char *str, ...) WARN_FORMAT(1, 2); void NORETURN CDECL assert_msg_error(int line, const char *file, const char *expr, const char *str, ...) WARN_FORMAT(4, 5);