Line data Source code
1 : #ifdef __PLUMED_HAS_ASMJIT 2 : // This file is part of AsmJit project <https://asmjit.com> 3 : // 4 : // See asmjit.h or LICENSE.md for license and copyright information 5 : // SPDX-License-Identifier: Zlib 6 : 7 : #include "api-build_p.h" 8 : #include "environment.h" 9 : 10 : ASMJIT_BEGIN_NAMESPACE 11 : 12 : // X86 Target 13 : // ---------- 14 : // 15 : // - 32-bit - Linux, OSX, BSD, and apparently also Haiku guarantee 16-byte 16 : // stack alignment. Other operating systems are assumed to have 17 : // 4-byte alignment by default for safety reasons. 18 : // - 64-bit - stack must be aligned to 16 bytes. 19 : // 20 : // ARM Target 21 : // ---------- 22 : // 23 : // - 32-bit - Stack must be aligned to 8 bytes. 24 : // - 64-bit - Stack must be aligned to 16 bytes (hardware requirement). 25 27492 : uint32_t Environment::stackAlignment() const noexcept { 26 27492 : if (is64Bit()) { 27 : // Assume 16-byte alignment on any 64-bit target. 28 : return 16; 29 : } 30 : else { 31 : // The following platforms use 16-byte alignment in 32-bit mode. 32 0 : if (isPlatformLinux() || 33 0 : isPlatformBSD() || 34 0 : isPlatformApple() || 35 : isPlatformHaiku()) { 36 : return 16u; 37 : } 38 : 39 0 : if (isFamilyARM()) 40 : return 8; 41 : 42 : // Bail to 4-byte alignment if we don't know. 43 0 : return 4; 44 : } 45 : } 46 : 47 : ASMJIT_END_NAMESPACE 48 : 49 : #endif // __PLUMED_HAS_ASMJIT