Crypto++ 8.7
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// The problems with Clang pretending to be other compilers is
31// discussed at http://github.com/weidai11/cryptopp/issues/147.
32#if (defined(_MSC_VER) && defined(__clang__) && \
33 !(defined( __clang_analyzer__)) && !defined(__INTEL_LLVM_COMPILER))
34# error: "Unsupported configuration"
35#endif
36
37// Windows platform
38#if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
39#define CRYPTOPP_WIN32_AVAILABLE
40#endif
41
42// Unix and Linux platforms
43#if defined(__unix__) || defined(__MACH__) || defined(__NetBSD__) || defined(__sun)
44#define CRYPTOPP_UNIX_AVAILABLE
45#endif
46
47// BSD platforms
48#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
49#define CRYPTOPP_BSD_AVAILABLE
50#endif
51
52// Microsoft compilers
53#if defined(_MSC_VER) || defined(__fastcall)
54 #define CRYPTOPP_FASTCALL __fastcall
55#else
56 #define CRYPTOPP_FASTCALL
57#endif
58
59// Microsoft compilers
60#if defined(_MSC_VER)
61 #define CRYPTOPP_NO_VTABLE __declspec(novtable)
62#else
63 #define CRYPTOPP_NO_VTABLE
64#endif
65
66// Define this if you want to disable all OS-dependent features,
67// such as sockets and OS-provided random number generators
68// #define NO_OS_DEPENDENCE
69
70// Define this to use features provided by Microsoft's CryptoAPI.
71// Currently the only feature used is Windows random number generation.
72// This macro will be ignored if NO_OS_DEPENDENCE is defined.
73// #define USE_MS_CRYPTOAPI
74
75// Define this to use features provided by Microsoft's CryptoNG API.
76// CryptoNG API is available in Vista and above and its cross platform,
77// including desktop apps and store apps. Currently the only feature
78// used is Windows random number generation.
79// This macro will be ignored if NO_OS_DEPENDENCE is defined.
80// #define USE_MS_CNGAPI
81
82// If the user did not make a choice, then select CryptoNG if
83// targeting Windows 8 or above.
84#if !defined(USE_MS_CRYPTOAPI) && !defined(USE_MS_CNGAPI)
85# if !defined(_USING_V110_SDK71_) && ((WINVER >= 0x0602 /*_WIN32_WINNT_WIN8*/) || \
86 (_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/))
87# define USE_MS_CNGAPI
88# else
89# define USE_MS_CRYPTOAPI
90# endif
91#endif
92
93// Begin OS features, like init priorities and random numbers
94#ifndef NO_OS_DEPENDENCE
95
96// CRYPTOPP_INIT_PRIORITY attempts to manage initialization of C++ static objects.
97// Under GCC, the library uses init_priority attribute in the range
98// [CRYPTOPP_INIT_PRIORITY, CRYPTOPP_INIT_PRIORITY+100]. Under Windows,
99// CRYPTOPP_INIT_PRIORITY enlists "#pragma init_seg(lib)". The platforms
100// with gaps are Apple and Sun because they require linker scripts. Apple and
101// Sun will use the library's Singletons to initialize and acquire resources.
102// Also see http://cryptopp.com/wiki/Static_Initialization_Order_Fiasco
103#ifndef CRYPTOPP_INIT_PRIORITY
104# define CRYPTOPP_INIT_PRIORITY 250
105#endif
106
107// CRYPTOPP_USER_PRIORITY is for other libraries and user code that is using Crypto++
108// and managing C++ static object creation. It is guaranteed not to conflict with
109// values used by (or would be used by) the Crypto++ library.
110#ifndef CRYPTOPP_USER_PRIORITY
111# define CRYPTOPP_USER_PRIORITY (CRYPTOPP_INIT_PRIORITY+101)
112#endif
113
114// Most platforms allow us to specify when to create C++ objects. Apple and Sun do not.
115#if (CRYPTOPP_INIT_PRIORITY > 0) && !(defined(NO_OS_DEPENDENCE) || defined(__APPLE__) || defined(__sun__))
116# if (CRYPTOPP_GCC_VERSION >= 30000) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20900) || (_INTEL_COMPILER >= 800)
117# define HAVE_GCC_INIT_PRIORITY 1
118# elif (CRYPTOPP_MSC_VERSION >= 1310)
119# define HAVE_MSC_INIT_PRIORITY 1
120# elif defined(__xlc__) || defined(__xlC__) || defined(__ibmxl__)
121# define HAVE_XLC_INIT_PRIORITY 1
122# endif
123#endif // CRYPTOPP_INIT_PRIORITY, NO_OS_DEPENDENCE, Apple, Sun
124
125#if defined(CRYPTOPP_WIN32_AVAILABLE) || defined(CRYPTOPP_UNIX_AVAILABLE)
126# define HIGHRES_TIMER_AVAILABLE
127#endif
128
129#ifdef CRYPTOPP_WIN32_AVAILABLE
130# if !defined(WINAPI_FAMILY)
131# define THREAD_TIMER_AVAILABLE
132# elif defined(WINAPI_FAMILY)
133# if (WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP))
134# define THREAD_TIMER_AVAILABLE
135# endif
136# endif
137#endif
138
139#if defined(CRYPTOPP_UNIX_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING)
140# define NONBLOCKING_RNG_AVAILABLE
141# define BLOCKING_RNG_AVAILABLE
142# define OS_RNG_AVAILABLE
143#endif
144
145// Cygwin/Newlib requires _XOPEN_SOURCE=600
146#if defined(CRYPTOPP_UNIX_AVAILABLE)
147# define UNIX_SIGNALS_AVAILABLE 1
148#endif
149
150#ifdef CRYPTOPP_WIN32_AVAILABLE
151# if !defined(WINAPI_FAMILY)
152# define NONBLOCKING_RNG_AVAILABLE
153# define OS_RNG_AVAILABLE
154# elif defined(WINAPI_FAMILY)
155# if (WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP))
156# define NONBLOCKING_RNG_AVAILABLE
157# define OS_RNG_AVAILABLE
158# elif !(WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP))
159# if ((WINVER >= 0x0A00 /*_WIN32_WINNT_WIN10*/) || (_WIN32_WINNT >= 0x0A00 /*_WIN32_WINNT_WIN10*/))
160# define NONBLOCKING_RNG_AVAILABLE
161# define OS_RNG_AVAILABLE
162# endif
163# endif
164# endif
165#endif
166
167#endif // NO_OS_DEPENDENCE
168
169#endif // CRYPTOPP_CONFIG_OS_H
Library configuration file.