Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/util/util_defines.h
| Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | |||||
| #if defined(__GNUC__) && defined(__KERNEL_CPU__) | #if defined(__GNUC__) && defined(__KERNEL_CPU__) | ||||
| # define LIKELY(x) __builtin_expect(!!(x), 1) | # define LIKELY(x) __builtin_expect(!!(x), 1) | ||||
| # define UNLIKELY(x) __builtin_expect(!!(x), 0) | # define UNLIKELY(x) __builtin_expect(!!(x), 0) | ||||
| #else | #else | ||||
| # define LIKELY(x) (x) | # define LIKELY(x) (x) | ||||
| # define UNLIKELY(x) (x) | # define UNLIKELY(x) (x) | ||||
| #endif | #endif | ||||
| #if defined(__cplusplus) && ((__cplusplus >= 201103L) || (defined(_MSC_VER) && _MSC_VER >= 1800)) | |||||
| # define HAS_CPP11_FEATURES | |||||
| #endif | |||||
| #if defined(__GNUC__) || defined(__clang__) | #if defined(__GNUC__) || defined(__clang__) | ||||
| # if defined(HAS_CPP11_FEATURES) | |||||
| /* Some magic to be sure we don't have reference in the type. */ | /* Some magic to be sure we don't have reference in the type. */ | ||||
| template<typename T> static inline T decltype_helper(T x) { return x; } | template<typename T> static inline T decltype_helper(T x) { return x; } | ||||
| # define TYPEOF(x) decltype(decltype_helper(x)) | # define TYPEOF(x) decltype(decltype_helper(x)) | ||||
| # else | |||||
| # define TYPEOF(x) typeof(x) | |||||
| # endif | |||||
| #endif | #endif | ||||
| /* Causes warning: | /* Causes warning: | ||||
| * incompatible types when assigning to type 'Foo' from type 'Bar' | * incompatible types when assigning to type 'Foo' from type 'Bar' | ||||
| * ... the compiler optimizes away the temp var */ | * ... the compiler optimizes away the temp var */ | ||||
| #ifdef __GNUC__ | #ifdef __GNUC__ | ||||
| #define CHECK_TYPE(var, type) { \ | #define CHECK_TYPE(var, type) { \ | ||||
| TYPEOF(var) *__tmp; \ | TYPEOF(var) *__tmp; \ | ||||
| Show All 26 Lines | |||||