|
2 | 2 | #define HD_INC_CORE_DEFINES_H |
3 | 3 | #include "compiler_defines.h" |
4 | 4 | #include "builtin.h" |
| 5 | +#include "traits/is_constant_evaluated.h" |
5 | 6 |
|
6 | 7 | #if defined(HD_COMPILER_GCC) |
7 | 8 | // Use __forceinline only in non debug mode |
|
14 | 15 | #define HD_RESTRICT __restrict__ // Indicates that a symbol is not aliased in the current scope. |
15 | 16 | #define __STDC_WANT_LIB_EXT1__ 1 // Enable bounds-checked functions ( ISO C Safe Array Functions : memcpy_s, strcpy_s, snwprintf_s, etc... ) |
16 | 17 |
|
17 | | - #if defined(HD_HAS_BUILTIN_UNREACHABLE) |
18 | | - #define HD_ASSUME(cond) \ |
19 | | - do \ |
20 | | - { \ |
21 | | - if (!(cond)) \ |
22 | | - __builtin_unreachable(); \ |
| 18 | + #if HD_HAS_BUILTIN_UNREACHABLE |
| 19 | + #define HD_ASSUME(cond) \ |
| 20 | + do \ |
| 21 | + { \ |
| 22 | + if (!hud::is_constant_evaluated()) \ |
| 23 | + { \ |
| 24 | + if (!(cond)) \ |
| 25 | + __builtin_unreachable(); \ |
| 26 | + } \ |
23 | 27 | } while (false) |
24 | 28 | #else |
25 | 29 | #define HD_ASSUME(cond) \ |
|
50 | 54 | #define HD_RESTRICT __restrict__ // Indicates that a symbol is not aliased in the current scope. |
51 | 55 | #define __STDC_WANT_LIB_EXT1__ 1 // Enable bounds-checked functions ( ISO C Safe Array Functions : memcpy_s, strcpy_s, snwprintf_s, etc... ) |
52 | 56 |
|
53 | | - #if !defined(HD_RELEASE) |
54 | | - |
55 | | - #endif |
56 | | - #if defined(HD_HAS_BUILTIN_ASSUME) |
| 57 | + #if HD_HAS_BUILTIN_ASSUME |
57 | 58 | #define HD_ASSUME(cond) __builtin_assume(cond) |
58 | 59 | #else |
59 | | - #if defined(HD_HAS_BUILTIN_UNREACHABLE) |
| 60 | + #if HD_HAS_BUILTIN_UNREACHABLE |
60 | 61 | #define HD_ASSUME(cond) \ |
61 | 62 | do \ |
62 | 63 | { \ |
|
0 commit comments