27 #define SPOT_LIKELY(expr) __builtin_expect(!!(expr), 1)
28 #define SPOT_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
30 #define SPOT_LIKELY(expr) (expr)
31 #define SPOT_UNLIKELY(expr) (expr)
34 #ifdef __has_cpp_attribute
35 # if __has_cpp_attribute(deprecated) && __cplusplus >= 201402L
36 # define SPOT_DEPRECATED(msg) [[deprecated(msg)]]
37 # elif __has_cpp_attribute(gnu::deprecated)
38 # define SPOT_DEPRECATED(msg) [[gnu::deprecated(msg)]]
39 # elif __has_cpp_attribute(clang::deprecated)
40 # define SPOT_DEPRECATED(msg) [[clang::deprecated(msg)]]
43 #ifndef SPOT_DEPRECATED
45 # define SPOT_DEPRECATED(msg) __attribute__ ((deprecated))
46 # elif defined(_MSC_VER)
47 # define SPOT_DEPRECATED(msg) __declspec(deprecated)
49 # define SPOT_DEPRECATED(msg)
53 #if defined _WIN32 || defined __CYGWIN__
54 #define SPOT_HELPER_DLL_IMPORT __declspec(dllimport)
55 #define SPOT_HELPER_DLL_EXPORT __declspec(dllexport)
56 #define SPOT_HELPER_DLL_LOCAL
59 #define SPOT_HELPER_DLL_IMPORT __attribute__ ((visibility ("default")))
60 #define SPOT_HELPER_DLL_EXPORT __attribute__ ((visibility ("default")))
61 #define SPOT_HELPER_DLL_LOCAL __attribute__ ((visibility ("hidden")))
63 #define SPOT_HELPER_DLL_IMPORT
64 #define SPOT_HELPER_DLL_EXPORT
65 #define SPOT_HELPER_DLL_LOCAL
78 #define spot_assert__ assert
79 #if defined(SPOT_BUILD) or defined(SPOT_DEBUG)
80 #define SPOT_ASSERT(x) spot_assert__(x)
82 #define SPOT_ASSERT(x) while (0)
90 #define SPOT_API SPOT_HELPER_DLL_EXPORT
92 #define SPOT_API SPOT_HELPER_DLL_IMPORT
94 #define SPOT_LOCAL SPOT_HELPER_DLL_LOCAL
99 #define SPOT_API_VAR extern SPOT_API
110 #if defined __clang__ || defined __GNU__
111 # define SPOT_UNREACHABLE_BUILTIN() __builtin_unreachable()
112 # elif defined _MSC_VER
113 # define SPOT_UNREACHABLE_BUILTIN() __assume(0)
115 # define SPOT_UNREACHABLE_BUILTIN() abort()
120 #define SPOT_UNREACHABLE() do { \
121 SPOT_ASSERT(!("unreachable code reached")); \
122 SPOT_UNREACHABLE_BUILTIN(); \
125 #define SPOT_UNIMPLEMENTED() throw std::runtime_error("unimplemented");
130 #define SPOT_RETURN(code) -> decltype(code) { return code; }
137 #ifdef __has_cpp_attribute
138 # if __has_cpp_attribute(fallthrough) && __cplusplus > 201402L
139 # define SPOT_FALLTHROUGH [[fallthrough]]
140 # elif __has_cpp_attribute(clang::fallthrough)
141 # define SPOT_FALLTHROUGH [[clang::fallthrough]]
142 # elif __has_cpp_attribute(gnu::fallthrough)
143 # define SPOT_FALLTHROUGH [[gnu::fallthrough]]
146 #ifndef SPOT_FALLTHROUGH
150 # define SPOT_FALLTHROUGH [[clang::fallthrough]]
152 # define SPOT_FALLTHROUGH while (0)
161 : std::runtime_error(s)
Definition: common.hh:158