Crypto++
8.8
Free C++ class library of cryptographic schemes
config_misc.h
Go to the documentation of this file.
1
// config_misc.h - written and placed in public domain by Jeffrey Walton
2
// the bits that make up this source file are from the
3
// library's monolithic config.h.
4
5
/// \file config_misc.h
6
/// \brief Library configuration file
7
/// \details <tt>config_misc.h</tt> provides miscellaneous defines.
8
/// \details <tt>config.h</tt> was split into components in May 2019 to better
9
/// integrate with Autoconf and its feature tests. The splitting occurred so
10
/// users could continue to include <tt>config.h</tt> while allowing Autoconf
11
/// to write new <tt>config_asm.h</tt> and new <tt>config_cxx.h</tt> using
12
/// its feature tests.
13
/// \note You should include <tt>config.h</tt> rather than <tt>config_misc.h</tt>
14
/// directly.
15
/// \sa <A HREF="https://github.com/weidai11/cryptopp/issues/835">Issue 835,
16
/// Make config.h more autoconf friendly</A>,
17
/// <A HREF="https://www.cryptopp.com/wiki/Configure.sh">Configure.sh script</A>
18
/// on the Crypto++ wiki
19
/// \since Crypto++ 8.3
20
21
#ifndef CRYPTOPP_CONFIG_MISC_H
22
#define CRYPTOPP_CONFIG_MISC_H
23
24
#include "
config_asm.h
"
25
#include "
config_cxx.h
"
26
#include "
config_os.h
"
27
#include "
config_ver.h
"
28
29
// Define this if running on a big-endian CPU
30
// big endian will be assumed if CRYPTOPP_LITTLE_ENDIAN is not non-0
31
#if !defined(CRYPTOPP_LITTLE_ENDIAN) && !defined(CRYPTOPP_BIG_ENDIAN) && (defined(__BIG_ENDIAN__) || (defined(__s390__) || defined(__s390x__) || defined(__zarch__)) || (defined(__m68k__) || defined(__MC68K__)) || defined(__sparc) || defined(__sparc__) || defined(__hppa__) || defined(__MIPSEB__) || defined(__ARMEB__) || (defined(__MWERKS__) && !defined(__INTEL__)))
32
# define CRYPTOPP_BIG_ENDIAN 1
33
#endif
34
35
// Define this if running on a little-endian CPU
36
// big endian will be assumed if CRYPTOPP_LITTLE_ENDIAN is not non-0
37
#if !defined(CRYPTOPP_BIG_ENDIAN) && !defined(CRYPTOPP_LITTLE_ENDIAN)
38
# define CRYPTOPP_LITTLE_ENDIAN 1
39
#endif
40
41
// Define this if you want to set a prefix for TestData/ and TestVectors/
42
// Be sure to add the trailing slash since its simple concatenation.
43
// After https://github.com/weidai11/cryptopp/issues/760 the library
44
// should find the test vectors and data without much effort. It
45
// will search in "./" and "$ORIGIN/../share/cryptopp" automatically.
46
#ifndef CRYPTOPP_DATA_DIR
47
# define CRYPTOPP_DATA_DIR ""
48
#endif
49
50
// Define this to disable the test suite from searching for test
51
// vectors and data in "./" and "$ORIGIN/../share/cryptopp". The
52
// library will still search in CRYPTOPP_DATA_DIR, regardless.
53
// Some distros may want to disable this feature. Also see
54
// https://github.com/weidai11/cryptopp/issues/760
55
// #ifndef CRYPTOPP_DISABLE_DATA_DIR_SEARCH
56
// # define CRYPTOPP_DISABLE_DATA_DIR_SEARCH
57
// #endif
58
59
// Define this if you want or need the library's memcpy_s and memmove_s.
60
// See http://github.com/weidai11/cryptopp/issues/28.
61
// #if !defined(CRYPTOPP_WANT_SECURE_LIB)
62
// # define CRYPTOPP_WANT_SECURE_LIB
63
// #endif
64
65
// Define this if ARMv8 shifts are slow. ARM Cortex-A53 and Cortex-A57 shift
66
// operation perform poorly, so NEON and ASIMD code that relies on shifts
67
// or rotates often performs worse than C/C++ code. Also see
68
// http://github.com/weidai11/cryptopp/issues/367.
69
#define CRYPTOPP_SLOW_ARMV8_SHIFT 1
70
71
// CRYPTOPP_DEBUG enables the library's CRYPTOPP_ASSERT. CRYPTOPP_ASSERT
72
// raises a SIGTRAP (Unix) or calls DebugBreak() (Windows). CRYPTOPP_ASSERT
73
// is only in effect when CRYPTOPP_DEBUG, DEBUG or _DEBUG is defined. Unlike
74
// Posix assert, CRYPTOPP_ASSERT is not affected by NDEBUG (or failure to
75
// define it). According to the ndk-build docs, Android use NDK_DEBUG=1 to
76
// signal a DEBUG build (and NDK_DEBUG=0 to signal non-DEBUG build).
77
// Also see http://github.com/weidai11/cryptopp/issues/277, CVE-2016-7420 and
78
// https://developer.android.com/ndk/guides/ndk-build
79
#if (defined(DEBUG) || defined(_DEBUG)) || (defined(NDK_DEBUG) && (NDK_DEBUG > 0))
80
# undef CRYPTOPP_DEBUG
81
# define CRYPTOPP_DEBUG 1
82
#endif
83
84
// File system code to use when creating GZIP archive.
85
// http://www.gzip.org/format.txt
86
#if !defined(GZIP_OS_CODE)
87
# if defined(__macintosh__)
88
# define GZIP_OS_CODE 7
89
# elif defined(__unix__) || defined(__linux__)
90
# define GZIP_OS_CODE 3
91
# else
92
# define GZIP_OS_CODE 0
93
# endif
94
#endif
95
96
// Try this if your CPU has 256K internal cache or a slow multiply instruction
97
// and you want a (possibly) faster IDEA implementation using log tables
98
// #define IDEA_LARGECACHE
99
100
// Define this if, for the linear congruential RNG, you want to use
101
// the original constants as specified in S.K. Park and K.W. Miller's
102
// CACM paper.
103
// #define LCRNG_ORIGINAL_NUMBERS
104
105
// Define this if you want Integer's operator<< to honor std::showbase (and
106
// std::noshowbase). If defined, Integer will use a suffix of 'b', 'o', 'h'
107
// or '.' (the last for decimal) when std::showbase is in effect. If
108
// std::noshowbase is set, then the suffix is not added to the Integer. If
109
// not defined, existing behavior is preserved and Integer will use a suffix
110
// of 'b', 'o', 'h' or '.' (the last for decimal).
111
// #define CRYPTOPP_USE_STD_SHOWBASE
112
113
// Define this if you want to decouple AlgorithmParameters and Integer
114
// The decoupling should make it easier for the linker to remove Integer
115
// related code for those who do not need Integer, and avoid a potential
116
// race during AssignIntToInteger pointer initialization. Also
117
// see http://github.com/weidai11/cryptopp/issues/389.
118
// #define CRYPTOPP_NO_ASSIGN_TO_INTEGER
119
120
// Need GCC 4.6/Clang 1.7/Apple Clang 2.0 or above due to "GCC diagnostic {push|pop}"
121
#if (CRYPTOPP_GCC_VERSION >= 40600) || (CRYPTOPP_LLVM_CLANG_VERSION >= 10700) || \
122
(CRYPTOPP_APPLE_CLANG_VERSION >= 20000)
123
#define CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE 1
124
#endif
125
126
// Portable way to suppress warnings.
127
// Moved from misc.h due to circular depenedencies.
128
#ifndef CRYPTOPP_UNUSED
129
#define CRYPTOPP_UNUSED(x) ((void)(x))
130
#endif
131
132
// how to disable inlining
133
#if defined(_MSC_VER)
134
# define CRYPTOPP_NOINLINE_DOTDOTDOT
135
# define CRYPTOPP_NOINLINE __declspec(noinline)
136
#elif defined(__xlc__) || defined(__xlC__) || defined(__ibmxl__)
137
# define CRYPTOPP_NOINLINE_DOTDOTDOT ...
138
# define CRYPTOPP_NOINLINE __attribute__((noinline))
139
#elif defined(__GNUC__)
140
# define CRYPTOPP_NOINLINE_DOTDOTDOT
141
# define CRYPTOPP_NOINLINE __attribute__((noinline))
142
#else
143
# define CRYPTOPP_NOINLINE_DOTDOTDOT ...
144
# define CRYPTOPP_NOINLINE
145
#endif
146
147
// http://stackoverflow.com/a/13867690/608639
148
// CRYPTOPP_CONST_OR_CONSTEXPR due to https://github.com/weidai11/cryptopp/issues/1185
149
#if defined(CRYPTOPP_CXX11_CONSTEXPR)
150
# define CRYPTOPP_STATIC_CONSTEXPR static constexpr
151
# define CRYPTOPP_STATIC_CONST_OR_CONSTEXPR static constexpr
152
# define CRYPTOPP_CONST_OR_CONSTEXPR constexpr
153
# define CRYPTOPP_CONSTEXPR constexpr
154
#else
155
# define CRYPTOPP_STATIC_CONSTEXPR static
156
# define CRYPTOPP_STATIC_CONST_OR_CONSTEXPR static const
157
# define CRYPTOPP_CONST_OR_CONSTEXPR const
158
# define CRYPTOPP_CONSTEXPR
159
#endif // CRYPTOPP_CXX11_CONSTEXPR
160
161
#if defined(CRYPTOPP_DOXYGEN_PROCESSING)
162
# define CRYPTOPP_CONSTANT(x) static const int x
163
#elif defined(CRYPTOPP_CXX11_STRONG_ENUM)
164
# define CRYPTOPP_CONSTANT(x) enum : int { x }
165
#elif defined(CRYPTOPP_CXX11_CONSTEXPR)
166
# define CRYPTOPP_CONSTANT(x) constexpr static int x
167
#else
168
# define CRYPTOPP_CONSTANT(x) static const int x
169
#endif
170
171
// Warnings
172
#ifdef _MSC_VER
173
// 4127: conditional expression is constant
174
// 4512: assignment operator not generated
175
// 4661: no suitable definition provided for explicit template instantiation request
176
// 4910: '__declspec(dllexport)' and 'extern' are incompatible on an explicit instantiation
177
# pragma warning(disable: 4127 4512 4661 4910)
178
// _MSC_VER 1920 is VS2019
179
# if _MSC_VER >= 1920
180
// 5054: operator '|': deprecated between enumerations of different types
181
# pragma warning(disable: 5054)
182
# endif
183
// Security related, possible defects
184
// http://blogs.msdn.com/b/vcblog/archive/2010/12/14/off-by-default-compiler-warnings-in-visual-c.aspx
185
# pragma warning(once: 4191 4242 4263 4264 4266 4302 4826 4905 4906 4928)
186
#endif
187
188
#ifdef __BORLANDC__
189
// 8037: non-const function called for const object. needed to work around BCB2006 bug
190
# pragma warn -8037
191
#endif
192
193
// [GCC Bug 53431] "C++ preprocessor ignores #pragma GCC diagnostic". Clang honors it.
194
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
195
# pragma GCC diagnostic ignored "-Wunknown-pragmas"
196
# pragma GCC diagnostic ignored "-Wunused-function"
197
#endif
198
199
#endif // CRYPTOPP_CONFIG_MISC_H
config_asm.h
Library configuration file.
config_cxx.h
Library configuration file.
config_os.h
Library configuration file.
config_ver.h
Library configuration file.
Generated on Fri Jun 14 2024 14:11:58 for Crypto++ by
1.8.17