1 #ifndef RBIMPL_ASSUME_H
2 #define RBIMPL_ASSUME_H
28 #include "ruby/internal/config.h"
29 #include "ruby/internal/cast.h"
35 #if defined(HAVE___ASSUME)
36 # define RBIMPL_HAVE___ASSUME
41 #if RBIMPL_HAS_BUILTIN(__builtin_unreachable)
42 # define RBIMPL_UNREACHABLE_RETURN(_) __builtin_unreachable()
44 #elif defined(RBIMPL_HAVE___ASSUME)
45 # define RBIMPL_UNREACHABLE_RETURN(_) return (__assume(0), (_))
48 # define RBIMPL_UNREACHABLE_RETURN(_) return (_)
52 #if RBIMPL_HAS_BUILTIN(__builtin_unreachable)
53 # define RBIMPL_UNREACHABLE __builtin_unreachable
55 #elif defined(RBIMPL_HAVE___ASSUME)
56 # define RBIMPL_UNREACHABLE() __assume(0)
60 #if RBIMPL_COMPILER_SINCE(Intel, 13, 0, 0)
63 # define RBIMPL_ASSUME(expr) \
64 RBIMPL_WARNING_PUSH() \
65 RBIMPL_WARNING_IGNORED(2261) \
69 #elif defined(RBIMPL_HAVE___ASSUME)
70 # define RBIMPL_ASSUME __assume
72 #elif RBIMPL_HAS_BUILTIN(__builtin_assume)
73 # define RBIMPL_ASSUME __builtin_assume
75 #elif ! defined(RBIMPL_UNREACHABLE)
76 # define RBIMPL_ASSUME(_) RBIMPL_CAST((void)(_))
79 # define RBIMPL_ASSUME(_) \
80 (RB_LIKELY(!!(_)) ? RBIMPL_CAST((void)0) : RBIMPL_UNREACHABLE())
83 #if ! defined(RBIMPL_UNREACHABLE)
84 # define RBIMPL_UNREACHABLE() RBIMPL_ASSUME(0)
Defines RBIMPL_COMPILER_SINCE.
Defines RBIMPL_HAS_BUILTIN.
Defines RBIMPL_WARNING_PUSH.