]>
git.saurik.com Git - apple/libc.git/blob - gen/assumes.h
4f266c445d5a3b81bbffbb3fc89487b495596385
1 #ifndef __OSX_ASSUMES_H__
2 #define __OSX_ASSUMES_H__
8 #include <Availability.h>
16 #define osx_fastpath(x) ((typeof(x))__builtin_expect((long)(x), ~0l))
17 #define osx_slowpath(x) ((typeof(x))__builtin_expect((long)(x), 0l))
18 #define osx_constant(x) __builtin_constant_p((x))
20 #define __OSX_COMPILETIME_ASSERT__(e) ({ \
21 char __compile_time_assert__[(e) ? 1 : -1]; \
22 (void)__compile_time_assert__; \
25 #define osx_fastpath(x) (x)
26 #define osx_slowpath(x) (x)
27 #define osx_constant(x) ((long)0)
29 #define __OSX_COMPILETIME_ASSERT__(e) (e)
32 #define osx_assumes(e) ({ \
33 typeof(e) _e = osx_fastpath(e); /* Force evaluation of 'e' */ \
35 if (osx_constant(e)) { \
36 __OSX_COMPILETIME_ASSERT__(e); \
38 _osx_assumes_log((uintptr_t)_e); \
43 #define osx_assumes_zero(e) ({ \
44 typeof(e) _e = osx_slowpath(e); /* Force evaluation of 'e' */ \
46 if (osx_constant(e)) { \
47 __OSX_COMPILETIME_ASSERT__(!e); \
49 _osx_assumes_log((uintptr_t)_e); \
54 __OSX_AVAILABLE_STARTING(__MAC_10_7
, __IPHONE_4_3
)
56 _osx_assumes_log(uint64_t code
);
60 #endif /* __OSX_ASSUMES_H__ */