Skip to content

Commit 817f2a7

Browse files
committed
Common/Compiler: Introduced XR_ASSUME() macro.
There is the only one "assume" usage yet, but the macro is useful for future optimization.
1 parent da996ce commit 817f2a7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Common/Compiler.inl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
#define XR_IMPORT __declspec(dllimport)
1515
#endif
1616

17+
#if defined(__GNUC__)
18+
#define XR_ASSUME(expr) if (expr){} else __builtin_unreachable()
19+
#elif defined(_MSC_VER)
20+
#define XR_ASSUME(expr) __assume(expr)
21+
#endif
22+
1723
#if defined(__GNUC__)
1824
#define NO_INLINE __attribute__((noinline))
1925
#define FORCE_INLINE __attribute__((always_inline)) inline

0 commit comments

Comments
 (0)