From ea3b47d0adbca633d330b6f6cb5682f7c3f2cff8 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 23 Apr 2017 13:25:13 +0300 Subject: [PATCH] Added generic workaround for double type alignment This fixes not only 32-bit Linux/macOS builds but PowerPC Mac target too --- src/scripting/types.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/scripting/types.cpp b/src/scripting/types.cpp index 82263dfcd..f07356d42 100644 --- a/src/scripting/types.cpp +++ b/src/scripting/types.cpp @@ -705,14 +705,13 @@ PFloat::PFloat(unsigned int size) Flags |= TYPE_Float; if (size == 8) { -#ifdef __i386__ - // According to System V i386 ABI alignment of double type is 4 - // GCC and Clang for 32-bit Intel targets follow this requirement - // However GCC has -malign-double option to enable 8-byte alignment - // So calculation of the actual alignment is needed - struct AlignmentCheck { uint8_t i; double d; }; - Align = static_cast(offsetof(AlignmentCheck, d)); -#endif // __i386__ + if (sizeof(void*) == 4) + { + // Some ABIs for 32-bit platforms define alignment of double type as 4 bytes + // Intel POSIX (System V ABI) and PowerPC Macs are examples of those + struct AlignmentCheck { uint8_t i; double d; }; + Align = static_cast(offsetof(AlignmentCheck, d)); + } SetDoubleSymbols(); }