1 #ifndef BENCHMARK_INTERNAL_MACROS_H_ 2 #define BENCHMARK_INTERNAL_MACROS_H_ 3 4 /* Needed to detect STL */ 5 #include <cstdlib> 6 7 // clang-format off 8 9 #ifndef __has_feature 10 #define __has_feature(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 // WINAPI_FAMILY_PARTITION is defined in winapifamily.h. 42 // We include windows.h which implicitly includes winapifamily.h for compatibility. 43 #ifndef NOMINMAX 44 #define NOMINMAX 45 #endif 46 #include <windows.h> 47 #if defined(WINAPI_FAMILY_PARTITION) 48 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) 49 #define BENCHMARK_OS_WINDOWS_WIN32 1 50 #elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) 51 #define BENCHMARK_OS_WINDOWS_RT 1 52 #endif 53 #endif 54 #if defined(__MINGW32__) 55 #define BENCHMARK_OS_MINGW 1 56 #endif 57 #elif defined(__APPLE__) 58 #define BENCHMARK_OS_APPLE 1 59 #include "TargetConditionals.h" 60 #if defined(TARGET_OS_MAC) 61 #define BENCHMARK_OS_MACOSX 1 62 #if defined(TARGET_OS_IPHONE) 63 #define BENCHMARK_OS_IOS 1 64 #endif 65 #endif 66 #elif defined(__FreeBSD__) 67 #define BENCHMARK_OS_FREEBSD 1 68 #elif defined(__NetBSD__) 69 #define BENCHMARK_OS_NETBSD 1 70 #elif defined(__OpenBSD__) 71 #define BENCHMARK_OS_OPENBSD 1 72 #elif defined(__DragonFly__) 73 #define BENCHMARK_OS_DRAGONFLY 1 74 #elif defined(__linux__) 75 #define BENCHMARK_OS_LINUX 1 76 #elif defined(__native_client__) 77 #define BENCHMARK_OS_NACL 1 78 #elif defined(__EMSCRIPTEN__) 79 #define BENCHMARK_OS_EMSCRIPTEN 1 80 #elif defined(__rtems__) 81 #define BENCHMARK_OS_RTEMS 1 82 #elif defined(__Fuchsia__) 83 #define BENCHMARK_OS_FUCHSIA 1 84 #elif defined (__SVR4) && defined (__sun) 85 #define BENCHMARK_OS_SOLARIS 1 86 #elif defined(__QNX__) 87 #define BENCHMARK_OS_QNX 1 88 #elif defined(__MVS__) 89 #define BENCHMARK_OS_ZOS 1 90 #elif defined(__hexagon__) 91 #define BENCHMARK_OS_QURT 1 92 #endif 93 94 #if defined(__ANDROID__) && defined(__GLIBCXX__) 95 #define BENCHMARK_STL_ANDROID_GNUSTL 1 96 #endif 97 98 #if !__has_feature(cxx_exceptions) && !defined(__cpp_exceptions) \ 99 && !defined(__EXCEPTIONS) 100 #define BENCHMARK_HAS_NO_EXCEPTIONS 101 #endif 102 103 #if defined(COMPILER_CLANG) || defined(COMPILER_GCC) 104 #define BENCHMARK_MAYBE_UNUSED __attribute__((unused)) 105 #else 106 #define BENCHMARK_MAYBE_UNUSED 107 #endif 108 109 // clang-format on 110 111 #endif // BENCHMARK_INTERNAL_MACROS_H_ 112