1 #ifndef BENCHMARK_INTERNAL_MACROS_H_
2 #define BENCHMARK_INTERNAL_MACROS_H_
3 
4 #include "benchmark/benchmark.h"
5 
6 #ifndef __has_feature
7 #define __has_feature(x) 0
8 #endif
9 #ifndef __has_builtin
10 #define __has_builtin(x) 0
11 #endif
12 
13 #if defined(__clang__)
14   #if !defined(COMPILER_CLANG)
15     #define COMPILER_CLANG
16   #endif
17 #elif defined(_MSC_VER)
18   #if !defined(COMPILER_MSVC)
19     #define COMPILER_MSVC
20   #endif
21 #elif defined(__GNUC__)
22   #if !defined(COMPILER_GCC)
23     #define COMPILER_GCC
24   #endif
25 #endif
26 
27 #if __has_feature(cxx_attributes)
28   #define BENCHMARK_NORETURN [[noreturn]]
29 #elif defined(__GNUC__)
30   #define BENCHMARK_NORETURN __attribute__((noreturn))
31 #elif defined(COMPILER_MSVC)
32   #define BENCHMARK_NORETURN __declspec(noreturn)
33 #else
34   #define BENCHMARK_NORETURN
35 #endif
36 
37 #if defined(__CYGWIN__)
38   #define BENCHMARK_OS_CYGWIN 1
39 #elif defined(_WIN32)
40   #define BENCHMARK_OS_WINDOWS 1
41 #elif defined(__APPLE__)
42   #define BENCHMARK_OS_APPLE 1
43   #include "TargetConditionals.h"
44   #if defined(TARGET_OS_MAC)
45     #define BENCHMARK_OS_MACOSX 1
46     #if defined(TARGET_OS_IPHONE)
47       #define BENCHMARK_OS_IOS 1
48     #endif
49   #endif
50 #elif defined(__FreeBSD__)
51   #define BENCHMARK_OS_FREEBSD 1
52 #elif defined(__NetBSD__)
53   #define BENCHMARK_OS_NETBSD 1
54 #elif defined(__OpenBSD__)
55   #define BENCHMARK_OS_OPENBSD 1
56 #elif defined(__linux__)
57   #define BENCHMARK_OS_LINUX 1
58 #elif defined(__native_client__)
59   #define BENCHMARK_OS_NACL 1
60 #elif defined(__EMSCRIPTEN__)
61   #define BENCHMARK_OS_EMSCRIPTEN 1
62 #elif defined(__rtems__)
63   #define BENCHMARK_OS_RTEMS 1
64 #elif defined(__Fuchsia__)
65 #define BENCHMARK_OS_FUCHSIA 1
66 #elif defined (__SVR4) && defined (__sun)
67 #define BENCHMARK_OS_SOLARIS 1
68 #endif
69 
70 #if !__has_feature(cxx_exceptions) && !defined(__cpp_exceptions) \
71      && !defined(__EXCEPTIONS)
72   #define BENCHMARK_HAS_NO_EXCEPTIONS
73 #endif
74 
75 #if defined(COMPILER_CLANG) || defined(COMPILER_GCC)
76   #define BENCHMARK_MAYBE_UNUSED __attribute__((unused))
77 #else
78   #define BENCHMARK_MAYBE_UNUSED
79 #endif
80 
81 #if defined(COMPILER_GCC) || __has_builtin(__builtin_unreachable)
82   #define BENCHMARK_UNREACHABLE() __builtin_unreachable()
83 #elif defined(COMPILER_MSVC)
84   #define BENCHMARK_UNREACHABLE() __assume(false)
85 #else
86   #define BENCHMARK_UNREACHABLE() ((void)0)
87 #endif
88 
89 #endif  // BENCHMARK_INTERNAL_MACROS_H_
90