Botan 3.14.1
Crypto and TLS for C&
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/api.h>
12
13// NOLINTBEGIN(*-macro-usage)
14
16
17/*
18* Define BOTAN_COMPILER_HAS_BUILTIN
19*/
20#if defined(__has_builtin)
21 #define BOTAN_COMPILER_HAS_BUILTIN(x) __has_builtin(x)
22#else
23 #define BOTAN_COMPILER_HAS_BUILTIN(x) 0
24#endif
25
26/*
27* Define BOTAN_COMPILER_HAS_ATTRIBUTE
28*/
29#if defined(__has_attribute)
30 #define BOTAN_COMPILER_HAS_ATTRIBUTE(x) __has_attribute(x)
31 #define BOTAN_COMPILER_ATTRIBUTE(x) __attribute__((x))
32#else
33 #define BOTAN_COMPILER_HAS_ATTRIBUTE(x) 0
34 #define BOTAN_COMPILER_ATTRIBUTE(x) /**/
35#endif
36
37/*
38* Hack for Loongarch64 GCC bug
39*
40* For some reason __has_attribute(target) is true, but it does not support the
41* target attribute... this supposedly is fixed in GCC 15 but this is untested.
42*/
43#if defined(__GNUC__) && defined(__loongarch64) && (__GNUC__ <= 14)
44 #define BOTAN_COMPILER_DOES_NOT_HAVE_TARGET_ATTRIBUTE
45#endif
46
47/*
48* Define BOTAN_FUNC_ISA
49*
50* TODO(Botan4) Move this to isa_extn.h
51*/
52#if BOTAN_COMPILER_HAS_ATTRIBUTE(target) && !defined(BOTAN_COMPILER_DOES_NOT_HAVE_TARGET_ATTRIBUTE)
53 #define BOTAN_FUNC_ISA(isa) BOTAN_COMPILER_ATTRIBUTE(target(isa))
54#else
55 #define BOTAN_FUNC_ISA(isa)
56#endif
57
58/*
59* Define BOTAN_FUNC_ISA_INLINE
60*
61* TODO(Botan4) Remove this
62*/
63#define BOTAN_FUNC_ISA_INLINE(isa) BOTAN_FUNC_ISA(isa) BOTAN_FORCE_INLINE
64
65/*
66* Define BOTAN_EARLY_INIT
67*/
68#if BOTAN_COMPILER_HAS_ATTRIBUTE(init_priority)
69 #define BOTAN_EARLY_INIT(prio) BOTAN_COMPILER_ATTRIBUTE(init_priority(prio))
70#else
71 #define BOTAN_EARLY_INIT(prio) /**/
72#endif
73
74/*
75* Define BOTAN_FORCE_INLINE
76*/
77#if !defined(BOTAN_FORCE_INLINE)
78
79 #if BOTAN_COMPILER_HAS_ATTRIBUTE(always_inline)
80 #define BOTAN_FORCE_INLINE inline BOTAN_COMPILER_ATTRIBUTE(always_inline)
81
82 #elif defined(_MSC_VER)
83 #define BOTAN_FORCE_INLINE __forceinline
84
85 #else
86 #define BOTAN_FORCE_INLINE inline
87 #endif
88
89#endif
90
91// NOLINTEND(*-macro-usage)
92
93#endif
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition api.h:104