mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-23 00:34:03 +02:00
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: Steven Noonan <steven@uplinklabs.net>
This commit is contained in:
+12
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user