File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 3232#define RBS_ATTRIBUTE_FORMAT (string_index , argument_index )
3333#endif
3434
35+ /**
36+ * Support RBS_LIKELY and RBS_UNLIKELY to help the compiler optimize its
37+ * branch predication.
38+ */
39+ #if defined(__GNUC__ ) || defined(__clang__ )
40+ /** The compiler should predicate that this branch will be taken. */
41+ #define RBS_LIKELY (x ) __builtin_expect(!!(x), 1)
42+
43+ /** The compiler should predicate that this branch will not be taken. */
44+ #define RBS_UNLIKELY (x ) __builtin_expect(!!(x), 0)
45+ #else
46+ /** Void because this platform does not support branch prediction hints. */
47+ #define RBS_LIKELY (x ) (x)
48+
49+ /** Void because this platform does not support branch prediction hints. */
50+ #define RBS_UNLIKELY (x ) (x)
51+ #endif
52+
3553/**
3654 * We use -Wimplicit-fallthrough to guard potentially unintended fall-through between cases of a switch.
3755 * Use RBS_FALLTHROUGH to explicitly annotate cases where the fallthrough is intentional.
You can’t perform that action at this time.
0 commit comments