Skip to content

Commit eb4a8d8

Browse files
author
Julian LALU
committed
Fix compilations
1 parent 6d3b043 commit eb4a8d8

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

interface/core/defines.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define HD_INC_CORE_DEFINES_H
33
#include "compiler_defines.h"
44
#include "builtin.h"
5+
#include "traits/is_constant_evaluated.h"
56

67
#if defined(HD_COMPILER_GCC)
78
// Use __forceinline only in non debug mode
@@ -14,12 +15,15 @@
1415
#define HD_RESTRICT __restrict__ // Indicates that a symbol is not aliased in the current scope.
1516
#define __STDC_WANT_LIB_EXT1__ 1 // Enable bounds-checked functions ( ISO C Safe Array Functions : memcpy_s, strcpy_s, snwprintf_s, etc... )
1617

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+
} \
2327
} while (false)
2428
#else
2529
#define HD_ASSUME(cond) \
@@ -50,13 +54,10 @@
5054
#define HD_RESTRICT __restrict__ // Indicates that a symbol is not aliased in the current scope.
5155
#define __STDC_WANT_LIB_EXT1__ 1 // Enable bounds-checked functions ( ISO C Safe Array Functions : memcpy_s, strcpy_s, snwprintf_s, etc... )
5256

53-
#if !defined(HD_RELEASE)
54-
55-
#endif
56-
#if defined(HD_HAS_BUILTIN_ASSUME)
57+
#if HD_HAS_BUILTIN_ASSUME
5758
#define HD_ASSUME(cond) __builtin_assume(cond)
5859
#else
59-
#if defined(HD_HAS_BUILTIN_UNREACHABLE)
60+
#if HD_HAS_BUILTIN_UNREACHABLE
6061
#define HD_ASSUME(cond) \
6162
do \
6263
{ \

0 commit comments

Comments
 (0)