benchmark
1.10.0
Toggle main menu visibility
Loading...
Searching...
No Matches
internal_macros.h
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(__wasi__)
81
#define BENCHMARK_OS_WASI 1
82
#elif defined(__rtems__)
83
#define BENCHMARK_OS_RTEMS 1
84
#elif defined(__Fuchsia__)
85
#define BENCHMARK_OS_FUCHSIA 1
86
#elif defined (__SVR4) && defined (__sun)
87
#define BENCHMARK_OS_SOLARIS 1
88
#elif defined(__QNX__)
89
#define BENCHMARK_OS_QNX 1
90
#elif defined(__MVS__)
91
#define BENCHMARK_OS_ZOS 1
92
#elif defined(__hexagon__)
93
#define BENCHMARK_OS_QURT 1
94
#endif
95
96
#if defined(__ANDROID__) && defined(__GLIBCXX__)
97
#define BENCHMARK_STL_ANDROID_GNUSTL 1
98
#endif
99
100
#if !__has_feature(cxx_exceptions) && !defined(__cpp_exceptions) \
101
&& !defined(__EXCEPTIONS)
102
#define BENCHMARK_HAS_NO_EXCEPTIONS
103
#endif
104
105
#if defined(COMPILER_CLANG) || defined(COMPILER_GCC)
106
#define BENCHMARK_MAYBE_UNUSED __attribute__((unused))
107
#else
108
#define BENCHMARK_MAYBE_UNUSED
109
#endif
110
111
#if defined(__GNUC__) || defined(__clang__)
112
#define PRINTF_FORMAT_STRING_FUNC(format_arg, first_idx) \
113
__attribute__((format(printf, format_arg, first_idx)))
114
#elif defined(__MINGW32__)
115
#define PRINTF_FORMAT_STRING_FUNC(format_arg, first_idx) \
116
__attribute__((format(__MINGW_PRINTF_FORMAT, format_arg, first_idx)))
117
#else
118
#define PRINTF_FORMAT_STRING_FUNC(format_arg, first_idx)
119
#endif
120
121
// clang-format on
122
123
#endif
// BENCHMARK_INTERNAL_MACROS_H_
src
internal_macros.h
Generated by
1.18.0