| 7 | #include "../core/environment.h" |
| 8 | |
| 9 | ASMJIT_BEGIN_NAMESPACE |
| 10 | |
| 11 | // X86 Target |
| 12 | // ---------- |
| 13 | // |
| 14 | // - 32-bit - Linux, OSX, BSD, and apparently also Haiku guarantee 16-byte |
| 15 | // stack alignment. Other operating systems are assumed to have |
| 16 | // 4-byte alignment by default for safety reasons. |
| 17 | // - 64-bit - stack must be aligned to 16 bytes. |
| 18 | // |
| 19 | // ARM Target |
| 20 | // ---------- |
| 21 | // |
| 22 | // - 32-bit - Stack must be aligned to 8 bytes. |
| 23 | // - 64-bit - Stack must be aligned to 16 bytes (hardware requirement). |
| 24 | uint32_t Environment::stackAlignment() const noexcept { |
| 25 | if (is64Bit()) { |
| 26 | // Assume 16-byte alignment on any 64-bit target. |
| 27 | return 16; |
| 28 | } |
| 29 | else { |
| 30 | // The following platforms use 16-byte alignment in 32-bit mode. |
| 31 | if (isPlatformLinux() || |
| 32 | isPlatformBSD() || |
| 33 | isPlatformApple() || |
| 34 | isPlatformHaiku()) { |
| 35 | return 16u; |
| 36 | } |
| 37 | |
| 38 | if (isFamilyARM()) |
| 39 | return 8; |
| 40 | |
| 41 | // Bail to 4-byte alignment if we don't know. |
| 42 | return 4; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | ASMJIT_END_NAMESPACE |
no test coverage detected