Botan
3.2.0
Crypto and TLS for C&
src
lib
utils
compiler.h
Go to the documentation of this file.
1
/*
2
* Define useful compiler-specific macros
3
* (C) 2016 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7
8
#ifndef BOTAN_UTIL_COMPILER_FLAGS_H_
9
#define BOTAN_UTIL_COMPILER_FLAGS_H_
10
11
#include <botan/build.h>
12
13
/**
14
* Used to annotate API exports which are public and supported.
15
* These APIs will not be broken/removed unless strictly required for
16
* functionality or security, and only in new major versions.
17
* @param maj The major version this public API was released in
18
* @param min The minor version this public API was released in
19
*/
20
#define BOTAN_PUBLIC_API(maj, min) BOTAN_DLL
21
22
/**
23
* Used to annotate API exports which are public, but are now deprecated
24
* and which will be removed in a future major release.
25
*/
26
#define BOTAN_DEPRECATED_API(msg) BOTAN_DLL BOTAN_DEPRECATED(msg)
27
28
/**
29
* Used to annotate API exports which are public and can be used by
30
* applications if needed, but which are intentionally not documented,
31
* and which may change incompatibly in a future major version.
32
*/
33
#define BOTAN_UNSTABLE_API BOTAN_DLL
34
35
/**
36
* Used to annotate API exports which are exported but only for the
37
* purposes of testing. They should not be used by applications and
38
* may be removed or changed without notice.
39
*/
40
#define BOTAN_TEST_API BOTAN_DLL
41
42
/**
43
* Used to annotate API exports which are exported but only for the
44
* purposes of fuzzing. They should not be used by applications and
45
* may be removed or changed without notice.
46
*
47
* They are only exported if the fuzzers are being built
48
*/
49
#if defined(BOTAN_FUZZERS_ARE_BEING_BUILT)
50
#define BOTAN_FUZZER_API BOTAN_DLL
51
#else
52
#define BOTAN_FUZZER_API
53
#endif
54
55
/*
56
* Define BOTAN_COMPILER_HAS_BUILTIN
57
*/
58
#if defined(__has_builtin)
59
#define BOTAN_COMPILER_HAS_BUILTIN(x) __has_builtin(x)
60
#else
61
#define BOTAN_COMPILER_HAS_BUILTIN(x) 0
62
#endif
63
64
/*
65
* Define BOTAN_COMPILER_HAS_ATTRIBUTE
66
*/
67
#if defined(__has_attribute)
68
#define BOTAN_COMPILER_HAS_ATTRIBUTE(x) __has_attribute(x)
69
#define BOTAN_COMPILER_ATTRIBUTE(x) __attribute__((x))
70
#else
71
#define BOTAN_COMPILER_HAS_ATTRIBUTE(x) 0
72
#define BOTAN_COMPILER_ATTRIBUTE(x)
/**/
73
#endif
74
75
/*
76
* Define BOTAN_FUNC_ISA
77
*/
78
#if BOTAN_COMPILER_HAS_ATTRIBUTE(target)
79
#define BOTAN_FUNC_ISA(isa) BOTAN_COMPILER_ATTRIBUTE(target(isa))
80
#else
81
#define BOTAN_FUNC_ISA(isa)
82
#endif
83
84
/*
85
* Define BOTAN_FUNC_ISA_INLINE
86
*/
87
#define BOTAN_FUNC_ISA_INLINE(isa) BOTAN_FUNC_ISA(isa) BOTAN_FORCE_INLINE
88
89
/*
90
* Define BOTAN_MALLOC_FN
91
*/
92
#if BOTAN_COMPILER_HAS_ATTRIBUTE(malloc)
93
#define BOTAN_MALLOC_FN BOTAN_COMPILER_ATTRIBUTE(malloc)
94
#elif defined(_MSC_VER)
95
#define BOTAN_MALLOC_FN __declspec(restrict)
96
#else
97
#define BOTAN_MALLOC_FN
98
#endif
99
100
/*
101
* Define BOTAN_EARLY_INIT
102
*/
103
#if BOTAN_COMPILER_HAS_ATTRIBUTE(init_priority)
104
#define BOTAN_EARLY_INIT(prio) BOTAN_COMPILER_ATTRIBUTE(init_priority(prio))
105
#else
106
#define BOTAN_EARLY_INIT(prio)
/**/
107
#endif
108
109
/*
110
* Define BOTAN_DEPRECATED
111
*/
112
#if !defined(BOTAN_NO_DEPRECATED_WARNINGS) && !defined(BOTAN_AMALGAMATION_H_) && !defined(BOTAN_IS_BEING_BUILT)
113
114
#define BOTAN_DEPRECATED(msg) [[deprecated(msg)]]
115
116
#if defined(__clang__)
117
#define BOTAN_DEPRECATED_HEADER(hdr) _Pragma("message \"this header is deprecated\"")
118
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr) _Pragma("message \"this header will be made internal in the future\"")
119
#elif defined(_MSC_VER)
120
#define BOTAN_DEPRECATED_HEADER(hdr) __pragma(message("this header is deprecated"))
121
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr) __pragma(message("this header will be made internal in the future"))
122
#elif defined(__GNUC__)
123
#define BOTAN_DEPRECATED_HEADER(hdr) _Pragma("GCC warning \"this header is deprecated\"")
124
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr) \
125
_Pragma("GCC warning \"this header will be made internal in the future\"")
126
#endif
127
128
#endif
129
130
#if !defined(BOTAN_DEPRECATED)
131
#define BOTAN_DEPRECATED(msg)
132
#endif
133
134
#if !defined(BOTAN_DEPRECATED_HEADER)
135
#define BOTAN_DEPRECATED_HEADER(hdr)
136
#endif
137
138
#if !defined(BOTAN_FUTURE_INTERNAL_HEADER)
139
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
140
#endif
141
142
/*
143
* Define BOTAN_FORCE_INLINE
144
*/
145
#if !defined(BOTAN_FORCE_INLINE)
146
147
#if BOTAN_COMPILER_HAS_ATTRIBUTE(always_inline)
148
#define BOTAN_FORCE_INLINE inline BOTAN_COMPILER_ATTRIBUTE(always_inline)
149
150
#elif defined(_MSC_VER)
151
#define BOTAN_FORCE_INLINE __forceinline
152
153
#else
154
#define BOTAN_FORCE_INLINE inline
155
#endif
156
157
#endif
158
159
/*
160
* Define BOTAN_PARALLEL_SIMD_FOR
161
*/
162
#if !defined(BOTAN_PARALLEL_SIMD_FOR)
163
164
#if defined(BOTAN_BUILD_COMPILER_IS_GCC)
165
#define BOTAN_PARALLEL_SIMD_FOR _Pragma("GCC ivdep") for
166
#else
167
#define BOTAN_PARALLEL_SIMD_FOR for
168
#endif
169
170
#endif
171
172
#if defined(BOTAN_BUILD_COMPILER_IS_GCC)
173
#define BOTAN_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
174
#define BOTAN_DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS \
175
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
176
#define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
177
#define BOTAN_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
178
#elif defined(BOTAN_BUILD_COMPILER_IS_CLANG)
179
#define BOTAN_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
180
#define BOTAN_DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS \
181
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
182
#define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
183
#define BOTAN_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
184
#elif defined(BOTAN_BUILD_COMPILER_IS_MSVC)
185
#define BOTAN_DIAGNOSTIC_PUSH __pragma(warning(push))
186
#define BOTAN_DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS __pragma(warning(disable : 4996))
187
#define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE __pragma(warning(disable : 4250))
188
#define BOTAN_DIAGNOSTIC_POP __pragma(warning(pop))
189
#else
190
#define BOTAN_DIAGNOSTIC_PUSH
191
#define BOTAN_DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS
192
#define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
193
#define BOTAN_DIAGNOSTIC_POP
194
#endif
195
196
#endif
Generated by
1.9.8