Crypto++ 8.4 Free C++ class library of cryptographic schemes

config_os.h
Go to the documentation of this file.
1 // config_os.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_os.h
6 /// \brief Library configuration file
7 /// \details <tt>config_os.h</tt> provides defines for platforms and operating
8 /// systems.
9 /// \details <tt>config.h</tt> was split into components in May 2019 to better
10 /// integrate with Autoconf and its feature tests. The splitting occurred so
11 /// users could continue to include <tt>config.h</tt> while allowing Autoconf
12 /// to write new <tt>config_asm.h</tt> and new <tt>config_cxx.h</tt> using
13 /// its feature tests.
14 /// \note You should include <tt>config.h</tt> rather than <tt>config_os.h</tt>
15 /// directly.
16 /// \sa <A HREF="https://github.com/weidai11/cryptopp/issues/835">Issue 835,
17 /// Make config.h more autoconf friendly</A>,
18 /// <A HREF="https://www.cryptopp.com/wiki/Configure.sh">Configure.sh script</A>
19 /// on the Crypto++ wiki
20 /// \since Crypto++ 8.3
21
22 #ifndef CRYPTOPP_CONFIG_OS_H
23 #define CRYPTOPP_CONFIG_OS_H
24
25 #include "config_ver.h"
26
27 // It is OK to remove the hard stop below, but you are on your own.
28 // After building the library be sure to run self tests described
29 // https://www.cryptopp.com/wiki/Release_Process#Self_Tests
30 // Some relevant bug reports can be found at:
31 // * Clang: http://github.com/weidai11/cryptopp/issues/147
32 #if (defined(_MSC_VER) && defined(__clang__) && !(defined( __clang_analyzer__)))
33 # error: "Unsupported configuration"
34 #endif
35
36 // Windows platform
37 #if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
38 #define CRYPTOPP_WIN32_AVAILABLE
39 #endif
40
41 // Unix and Linux platforms
42 #if defined(__unix__) || defined(__MACH__) || defined(__NetBSD__) || defined(__sun)
43 #define CRYPTOPP_UNIX_AVAILABLE
44 #endif
45
46 // BSD platforms
47 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
48 #define CRYPTOPP_BSD_AVAILABLE
49 #endif
50
51 // Microsoft compilers
52 #if defined(_MSC_VER) || defined(__fastcall)
53 #define CRYPTOPP_FASTCALL __fastcall
54 #else
55 #define CRYPTOPP_FASTCALL
56 #endif
57
58 // Microsoft compilers
59 #if defined(_MSC_VER)
60 #define CRYPTOPP_NO_VTABLE __declspec(novtable)
61 #else
62 #define CRYPTOPP_NO_VTABLE
63 #endif
64
65 // Define this if you want to disable all OS-dependent features,
66 // such as sockets and OS-provided random number generators
67 // #define NO_OS_DEPENDENCE
68
69 // Define this to use features provided by Microsoft's CryptoAPI.
70 // Currently the only feature used is Windows random number generation.
71 // This macro will be ignored if NO_OS_DEPENDENCE is defined.
72 // #define USE_MS_CRYPTOAPI
73
74 // Define this to use features provided by Microsoft's CryptoNG API.
75 // CryptoNG API is available in Vista and above and its cross platform,
76 // including desktop apps and store apps. Currently the only feature
77 // used is Windows random number generation.
78 // This macro will be ignored if NO_OS_DEPENDENCE is defined.
79 // #define USE_MS_CNGAPI
80
81 // If the user did not make a choice, then select CryptoNG if
82 // targeting Windows 8 or above.
83 #if !defined(USE_MS_CRYPTOAPI) && !defined(USE_MS_CNGAPI)
84 # if !defined(_USING_V110_SDK71_) && ((WINVER >= 0x0602 /*_WIN32_WINNT_WIN8*/) || \
85 (_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/))
86 # define USE_MS_CNGAPI
87 # else
88 # define USE_MS_CRYPTOAPI
89 # endif
90 #endif
91
92 // Begin OS features, like init priorities and random numbers
93 #ifndef NO_OS_DEPENDENCE
94
95 // CRYPTOPP_INIT_PRIORITY attempts to manage initialization of C++ static objects.
96 // Under GCC, the library uses init_priority attribute in the range
97 // [CRYPTOPP_INIT_PRIORITY, CRYPTOPP_INIT_PRIORITY+100]. Under Windows,
98 // CRYPTOPP_INIT_PRIORITY enlists "#pragma init_seg(lib)". The platforms
99 // with gaps are Apple and Sun because they require linker scripts. Apple and
100 // Sun will use the library's Singletons to initialize and acquire resources.
101 // Also see http://cryptopp.com/wiki/Static_Initialization_Order_Fiasco
102 #ifndef CRYPTOPP_INIT_PRIORITY
103 # define CRYPTOPP_INIT_PRIORITY 250
104 #endif
105
106 // CRYPTOPP_USER_PRIORITY is for other libraries and user code that is using Crypto++
107 // and managing C++ static object creation. It is guaranteed not to conflict with
108 // values used by (or would be used by) the Crypto++ library.
109 #ifndef CRYPTOPP_USER_PRIORITY
110 # define CRYPTOPP_USER_PRIORITY (CRYPTOPP_INIT_PRIORITY+101)
111 #endif
112
113 // Most platforms allow us to specify when to create C++ objects. Apple and Sun do not.
114 #if (CRYPTOPP_INIT_PRIORITY > 0) && !(defined(NO_OS_DEPENDENCE) || defined(__APPLE__) || defined(__sun__))
115 # if (CRYPTOPP_GCC_VERSION >= 30000) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20900) || (_INTEL_COMPILER >= 800)
116 # define HAVE_GCC_INIT_PRIORITY 1
117 # elif (CRYPTOPP_MSC_VERSION >= 1310)
118 # define HAVE_MSC_INIT_PRIORITY 1
119 # elif defined(__xlc__) || defined(__xlC__) || defined(__ibmxl__)
120 # define HAVE_XLC_INIT_PRIORITY 1
121 # endif
122 #endif // CRYPTOPP_INIT_PRIORITY, NO_OS_DEPENDENCE, Apple, Sun
123
124 #if defined(CRYPTOPP_WIN32_AVAILABLE) || defined(CRYPTOPP_UNIX_AVAILABLE)
125 # define HIGHRES_TIMER_AVAILABLE
126 #endif
127
128 #ifdef CRYPTOPP_WIN32_AVAILABLE
129 # if !defined(WINAPI_FAMILY)
130 # define THREAD_TIMER_AVAILABLE
131 # elif defined(WINAPI_FAMILY)
132 # if (WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP))
133 # define THREAD_TIMER_AVAILABLE
134 # endif
135 # endif
136 #endif
137
138 #if defined(CRYPTOPP_UNIX_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING)
139 # define NONBLOCKING_RNG_AVAILABLE
140 # define BLOCKING_RNG_AVAILABLE
141 # define OS_RNG_AVAILABLE
142 #endif
143
144 // Cygwin/Newlib requires _XOPEN_SOURCE=600
145 #if defined(CRYPTOPP_UNIX_AVAILABLE)
146 # define UNIX_SIGNALS_AVAILABLE 1
147 #endif
148
149 #ifdef CRYPTOPP_WIN32_AVAILABLE
150 # if !defined(WINAPI_FAMILY)
151 # define NONBLOCKING_RNG_AVAILABLE
152 # define OS_RNG_AVAILABLE
153 # elif defined(WINAPI_FAMILY)
154 # if (WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP))
155 # define NONBLOCKING_RNG_AVAILABLE
156 # define OS_RNG_AVAILABLE
157 # elif !(WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP))
158 # if ((WINVER >= 0x0A00 /*_WIN32_WINNT_WIN10*/) || (_WIN32_WINNT >= 0x0A00 /*_WIN32_WINNT_WIN10*/))
159 # define NONBLOCKING_RNG_AVAILABLE
160 # define OS_RNG_AVAILABLE
161 # endif
162 # endif
163 # endif
164 #endif
165
166 #endif // NO_OS_DEPENDENCE
167
168 #endif // CRYPTOPP_CONFIG_OS_H
config_ver.h
Library configuration file.