 |
Blender
V2.93
|
Go to the documentation of this file.
23 #ifndef __UTIL_DEFINES_H__
24 #define __UTIL_DEFINES_H__
28 #if defined(__ppc64__) || defined(__PPC64__) || defined(__x86_64__) || defined(__ia64__) || \
29 defined(_M_X64) || defined(__aarch64__)
30 # define __KERNEL_64_BIT__
35 #ifndef __KERNEL_GPU__
36 # define ccl_device static inline
37 # define ccl_device_noinline static
38 # define ccl_device_noinline_cpu ccl_device_noinline
40 # define ccl_static_constant static const
41 # define ccl_constant const
43 # define ccl_local_param
45 # define ccl_restrict __restrict
47 # define ccl_optional_struct_init
48 # define ccl_loop_no_unroll
49 # define __KERNEL_WITH_SSE_ALIGN__
51 # if defined(_WIN32) && !defined(FREE_WINDOWS)
52 # define ccl_device_inline static __forceinline
53 # define ccl_device_forceinline static __forceinline
54 # define ccl_align(...) __declspec(align(__VA_ARGS__))
55 # ifdef __KERNEL_64_BIT__
56 # define ccl_try_align(...) __declspec(align(__VA_ARGS__))
58 # undef __KERNEL_WITH_SSE_ALIGN__
60 # define ccl_try_align(...)
62 # define ccl_may_alias
63 # define ccl_always_inline __forceinline
64 # define ccl_never_inline __declspec(noinline)
65 # define ccl_maybe_unused
67 # define ccl_device_inline static inline __attribute__((always_inline))
68 # define ccl_device_forceinline static inline __attribute__((always_inline))
69 # define ccl_align(...) __attribute__((aligned(__VA_ARGS__)))
70 # ifndef FREE_WINDOWS64
71 # define __forceinline inline __attribute__((always_inline))
73 # define ccl_try_align(...) __attribute__((aligned(__VA_ARGS__)))
74 # define ccl_may_alias __attribute__((__may_alias__))
75 # define ccl_always_inline __attribute__((always_inline))
76 # define ccl_never_inline __attribute__((noinline))
77 # define ccl_maybe_unused __attribute__((used))
81 # ifndef ATTR_FALLTHROUGH
82 # if defined(__GNUC__) && (__GNUC__ >= 7)
83 # define ATTR_FALLTHROUGH __attribute__((fallthrough))
85 # define ATTR_FALLTHROUGH ((void)0)
93 #if defined(__GNUC__) && defined(__KERNEL_CPU__)
94 # define LIKELY(x) __builtin_expect(!!(x), 1)
95 # define UNLIKELY(x) __builtin_expect(!!(x), 0)
97 # define LIKELY(x) (x)
98 # define UNLIKELY(x) (x)
101 #if defined(__GNUC__) || defined(__clang__)
102 # if defined(__cplusplus)
104 template<
typename T>
static inline T decltype_helper(
T x)
108 # define TYPEOF(x) decltype(decltype_helper(x))
110 # define TYPEOF(x) typeof(x)
118 # define CHECK_TYPE(var, type) \
120 TYPEOF(var) * __tmp; \
121 __tmp = (type *)NULL; \
126 # define CHECK_TYPE_PAIR(var_a, var_b) \
128 TYPEOF(var_a) * __tmp; \
129 __tmp = (typeof(var_b) *)NULL; \
134 # define CHECK_TYPE(var, type)
135 # define CHECK_TYPE_PAIR(var_a, var_b)
139 #define CHECK_TYPE_INLINE(val, type) ((void)(((type)0) != (val)))
141 #ifndef __KERNEL_GPU__
143 # define util_assert(statement) assert(statement)
145 # define util_assert(statement)