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)
35 #define SPOT_DEPRECATED __attribute__ ((deprecated))
36 #elif defined(_MSC_VER)
37 #define SPOT_DEPRECATED __declspec(deprecated)
39 #define SPOT_DEPRECATED func
42 #if defined _WIN32 || defined __CYGWIN__
43 #define SPOT_HELPER_DLL_IMPORT __declspec(dllimport)
44 #define SPOT_HELPER_DLL_EXPORT __declspec(dllexport)
45 #define SPOT_HELPER_DLL_LOCAL
48 #define SPOT_HELPER_DLL_IMPORT __attribute__ ((visibility ("default")))
49 #define SPOT_HELPER_DLL_EXPORT __attribute__ ((visibility ("default")))
50 #define SPOT_HELPER_DLL_LOCAL __attribute__ ((visibility ("hidden")))
52 #define SPOT_HELPER_DLL_IMPORT
53 #define SPOT_HELPER_DLL_EXPORT
54 #define SPOT_HELPER_DLL_LOCAL
67 #define spot_assert__ assert
68 #if defined(SPOT_BUILD) or defined(SPOT_DEBUG)
69 #define SPOT_ASSERT(x) spot_assert__(x)
71 #define SPOT_ASSERT(x) while (0)
79 #define SPOT_API SPOT_HELPER_DLL_EXPORT
81 #define SPOT_API SPOT_HELPER_DLL_IMPORT
83 #define SPOT_LOCAL SPOT_HELPER_DLL_LOCAL
88 #define SPOT_API_VAR extern SPOT_API
99 #if defined __clang__ || defined __GNU__
100 # define SPOT_UNREACHABLE_BUILTIN() __builtin_unreachable()
101 # elif defined _MSC_VER
102 # define SPOT_UNREACHABLE_BUILTIN() __assume(0)
104 # define SPOT_UNREACHABLE_BUILTIN() abort()
109 #define SPOT_UNREACHABLE() do { \
110 SPOT_ASSERT(!("unreachable code reached")); \
111 SPOT_UNREACHABLE_BUILTIN(); \
114 #define SPOT_UNIMPLEMENTED() throw std::runtime_error("unimplemented");
119 #define SPOT_RETURN(code) -> decltype(code) { return code; }
123 #ifdef __has_cpp_attribute
124 # if __has_cpp_attribute(fallthrough)
125 # define SPOT_FALLTHROUGH [[fallthrough]]
126 # elif __has_cpp_attribute(clang::fallthrough)
127 # define SPOT_FALLTHROUGH [[clang::fallthrough]]
128 # elif __has_cpp_attribute(gcc::fallthrough)
129 # define SPOT_FALLTHROUGH [[gcc::fallthrough]]
132 #ifndef SPOT_FALLTHROUGH
136 # define SPOT_FALLTHROUGH [[clang::fallthrough]]
138 # define SPOT_FALLTHROUGH while (0)
147 : std::runtime_error(s)
Definition: common.hh:144