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)
36 # define SPOT_DEPRECATED [[deprecated]]
39 #ifndef SPOT_DEPRECATED
41 # define SPOT_DEPRECATED __attribute__ ((deprecated))
42 # elif defined(_MSC_VER)
43 # define SPOT_DEPRECATED __declspec(deprecated)
45 # define SPOT_DEPRECATED
49 #if defined _WIN32 || defined __CYGWIN__
50 #define SPOT_HELPER_DLL_IMPORT __declspec(dllimport)
51 #define SPOT_HELPER_DLL_EXPORT __declspec(dllexport)
52 #define SPOT_HELPER_DLL_LOCAL
55 #define SPOT_HELPER_DLL_IMPORT __attribute__ ((visibility ("default")))
56 #define SPOT_HELPER_DLL_EXPORT __attribute__ ((visibility ("default")))
57 #define SPOT_HELPER_DLL_LOCAL __attribute__ ((visibility ("hidden")))
59 #define SPOT_HELPER_DLL_IMPORT
60 #define SPOT_HELPER_DLL_EXPORT
61 #define SPOT_HELPER_DLL_LOCAL
74 #define spot_assert__ assert
75 #if defined(SPOT_BUILD) or defined(SPOT_DEBUG)
76 #define SPOT_ASSERT(x) spot_assert__(x)
78 #define SPOT_ASSERT(x) while (0)
86 #define SPOT_API SPOT_HELPER_DLL_EXPORT
88 #define SPOT_API SPOT_HELPER_DLL_IMPORT
90 #define SPOT_LOCAL SPOT_HELPER_DLL_LOCAL
95 #define SPOT_API_VAR extern SPOT_API
106 #if defined __clang__ || defined __GNU__
107 # define SPOT_UNREACHABLE_BUILTIN() __builtin_unreachable()
108 # elif defined _MSC_VER
109 # define SPOT_UNREACHABLE_BUILTIN() __assume(0)
111 # define SPOT_UNREACHABLE_BUILTIN() abort()
116 #define SPOT_UNREACHABLE() do { \
117 SPOT_ASSERT(!("unreachable code reached")); \
118 SPOT_UNREACHABLE_BUILTIN(); \
121 #define SPOT_UNIMPLEMENTED() throw std::runtime_error("unimplemented");
126 #define SPOT_RETURN(code) -> decltype(code) { return code; }
130 #ifdef __has_cpp_attribute
131 # if __has_cpp_attribute(fallthrough)
132 # define SPOT_FALLTHROUGH [[fallthrough]]
133 # elif __has_cpp_attribute(clang::fallthrough)
134 # define SPOT_FALLTHROUGH [[clang::fallthrough]]
135 # elif __has_cpp_attribute(gcc::fallthrough)
136 # define SPOT_FALLTHROUGH [[gcc::fallthrough]]
139 #ifndef SPOT_FALLTHROUGH
143 # define SPOT_FALLTHROUGH [[clang::fallthrough]]
145 # define SPOT_FALLTHROUGH while (0)
154 : std::runtime_error(s)
Definition: common.hh:151