Commit 5472d841 authored by Steven Noonan's avatar Steven Noonan

introduce MA_ASSUME macro

This macro can be used to tell the compiler's optimization passes static
assumptions which you *know* are true about code behavior.

Use of these can be risky -- if you assume incorrectly, the compiler may
emit code that will not work in circumstances you didn't anticipate.

On the other hand, use of this macro in places where the optimizer is
missing an assumption that would have been safe to make can cause it to
emit more compact/optimal code.
Signed-off-by: default avatarSteven Noonan <steven@uplinklabs.net>
parent c9e2258d
...@@ -6740,6 +6740,18 @@ static MA_INLINE ma_bool32 ma_has_neon(void) ...@@ -6740,6 +6740,18 @@ static MA_INLINE ma_bool32 ma_has_neon(void)
#define MA_COMPILER_HAS_BUILTIN(x) 0 #define MA_COMPILER_HAS_BUILTIN(x) 0
#endif #endif
#ifndef MA_ASSUME
#if MA_COMPILER_HAS_BUILTIN(__builtin_assume)
#define MA_ASSUME(x) __builtin_assume(x)
#elif MA_COMPILER_HAS_BUILTIN(__builtin_unreachable)
#define MA_ASSUME(x) do { if (!(x)) __builtin_unreachable(); } while (0)
#elif defined(_MSC_VER)
#define MA_ASSUME(x) __assume(x)
#else
#define MA_ASSUME(x) while(0)
#endif
#endif
#if defined(_MSC_VER) && _MSC_VER >= 1400 #if defined(_MSC_VER) && _MSC_VER >= 1400
#define MA_HAS_BYTESWAP16_INTRINSIC #define MA_HAS_BYTESWAP16_INTRINSIC
#define MA_HAS_BYTESWAP32_INTRINSIC #define MA_HAS_BYTESWAP32_INTRINSIC
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment