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(__ibmxl__) 15 #if !defined(COMPILER_IBMXL) 16 #define COMPILER_IBMXL 17 #endif 18 #elif !defined(COMPILER_CLANG) 19 #define COMPILER_CLANG 20 #endif 21 #elif defined(_MSC_VER) 22 #if !defined(COMPILER_MSVC) 23 #define COMPILER_MSVC 24 #endif 25 #elif defined(__GNUC__) 26 #if !defined(COMPILER_GCC) 27 #define COMPILER_GCC 28 #endif 29 #endif 30 31 #if __has_feature(cxx_attributes) 32 #define BENCHMARK_NORETURN [[noreturn]] 33 #elif defined(__GNUC__) 34 #define BENCHMARK_NORETURN __attribute__((noreturn)) 35 #elif defined(COMPILER_MSVC) 36 #define BENCHMARK_NORETURN __declspec(noreturn) 37 #else 38 #define BENCHMARK_NORETURN 39 #endif 40 41 #if defined(__CYGWIN__) 42 #define BENCHMARK_OS_CYGWIN 1 43 #elif defined(_WIN32) 44 #define BENCHMARK_OS_WINDOWS 1 45 // WINAPI_FAMILY_PARTITION is defined in winapifamily.h. 46 // We include windows.h which implicitly includes winapifamily.h for compatibility. 47 #ifndef NOMINMAX 48 #define NOMINMAX 49 #endif 50 #include <windows.h> 51 #if defined(WINAPI_FAMILY_PARTITION) 52 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) 53 #define BENCHMARK_OS_WINDOWS_WIN32 1 54 #elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) 55 #define BENCHMARK_OS_WINDOWS_RT 1 56 #endif 57 #endif 58 #if defined(__MINGW32__) 59 #define BENCHMARK_OS_MINGW 1 60 #endif 61 #elif defined(__APPLE__) 62 #define BENCHMARK_OS_APPLE 1 63 #include "TargetConditionals.h" 64 #if defined(TARGET_OS_MAC) 65 #define BENCHMARK_OS_MACOSX 1 66 #if defined(TARGET_OS_IPHONE) 67 #define BENCHMARK_OS_IOS 1 68 #endif 69 #endif 70 #elif defined(__FreeBSD__) 71 #define BENCHMARK_OS_FREEBSD 1 72 #elif defined(__NetBSD__) 73 #define BENCHMARK_OS_NETBSD 1 74 #elif defined(__OpenBSD__) 75 #define BENCHMARK_OS_OPENBSD 1 76 #elif defined(__DragonFly__) 77 #define BENCHMARK_OS_DRAGONFLY 1 78 #elif defined(__linux__) 79 #define BENCHMARK_OS_LINUX 1 80 #elif defined(__native_client__) 81 #define BENCHMARK_OS_NACL 1 82 #elif defined(__EMSCRIPTEN__) 83 #define BENCHMARK_OS_EMSCRIPTEN 1 84 #elif defined(__rtems__) 85 #define BENCHMARK_OS_RTEMS 1 86 #elif defined(__Fuchsia__) 87 #define BENCHMARK_OS_FUCHSIA 1 88 #elif defined (__SVR4) && defined (__sun) 89 #define BENCHMARK_OS_SOLARIS 1 90 #elif defined(__QNX__) 91 #define BENCHMARK_OS_QNX 1 92 #elif defined(__MVS__) 93 #define BENCHMARK_OS_ZOS 1 94 #elif defined(__hexagon__) 95 #define BENCHMARK_OS_QURT 1 96 #endif 97 98 #if defined(__ANDROID__) && defined(__GLIBCXX__) 99 #define BENCHMARK_STL_ANDROID_GNUSTL 1 100 #endif 101 102 #if !__has_feature(cxx_exceptions) && !defined(__cpp_exceptions) \ 103 && !defined(__EXCEPTIONS) 104 #define BENCHMARK_HAS_NO_EXCEPTIONS 105 #endif 106 107 #if defined(COMPILER_CLANG) || defined(COMPILER_GCC) 108 #define BENCHMARK_MAYBE_UNUSED __attribute__((unused)) 109 #else 110 #define BENCHMARK_MAYBE_UNUSED 111 #endif 112 113 // clang-format on 114 115 #endif // BENCHMARK_INTERNAL_MACROS_H_ 116