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