Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:54:55

0001 // config_os.h - written and placed in public domain by Jeffrey Walton

0002 //               the bits that make up this source file are from the

0003 //               library's monolithic config.h.

0004 
0005 /// \file config_os.h

0006 /// \brief Library configuration file

0007 /// \details <tt>config_os.h</tt> provides defines for platforms and operating

0008 ///  systems.

0009 /// \details <tt>config.h</tt> was split into components in May 2019 to better

0010 ///  integrate with Autoconf and its feature tests. The splitting occurred so

0011 ///  users could continue to include <tt>config.h</tt> while allowing Autoconf

0012 ///  to write new <tt>config_asm.h</tt> and new <tt>config_cxx.h</tt> using

0013 ///  its feature tests.

0014 /// \note You should include <tt>config.h</tt> rather than <tt>config_os.h</tt>

0015 ///  directly.

0016 /// \sa <A HREF="https://github.com/weidai11/cryptopp/issues/835">Issue 835,

0017 ///  Make config.h more autoconf friendly</A>,

0018 ///  <A HREF="https://www.cryptopp.com/wiki/Configure.sh">Configure.sh script</A>

0019 ///  on the Crypto++ wiki

0020 /// \since Crypto++ 8.3

0021 
0022 #ifndef CRYPTOPP_CONFIG_OS_H
0023 #define CRYPTOPP_CONFIG_OS_H
0024 
0025 #include "config_ver.h"
0026 
0027 // It is OK to remove the hard stop below, but you are on your own.

0028 // After building the library be sure to run self tests described

0029 // https://www.cryptopp.com/wiki/Release_Process#Self_Tests

0030 // The problems with Clang pretending to be other compilers is

0031 // discussed at http://github.com/weidai11/cryptopp/issues/147.

0032 #if (defined(_MSC_VER) && defined(__clang__))
0033 # error: "Unsupported configuration"
0034 #endif
0035 
0036 // Windows platform

0037 #if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
0038 #define CRYPTOPP_WIN32_AVAILABLE
0039 #endif
0040 
0041 // Unix and Linux platforms

0042 #if defined(__unix__) || defined(__MACH__) || defined(__NetBSD__) || defined(__sun)
0043 #define CRYPTOPP_UNIX_AVAILABLE
0044 #endif
0045 
0046 // BSD platforms

0047 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
0048 #define CRYPTOPP_BSD_AVAILABLE
0049 #endif
0050 
0051 // Microsoft compilers

0052 #if defined(CRYPTOPP_MSC_VERSION) || defined(__fastcall)
0053     #define CRYPTOPP_FASTCALL __fastcall
0054 #else
0055     #define CRYPTOPP_FASTCALL
0056 #endif
0057 
0058 // Microsoft compilers

0059 #if defined(CRYPTOPP_MSC_VERSION)
0060     #define CRYPTOPP_NO_VTABLE __declspec(novtable)
0061 #else
0062     #define CRYPTOPP_NO_VTABLE
0063 #endif
0064 
0065 // Define this if you want to disable all OS-dependent features,

0066 // such as sockets and OS-provided random number generators

0067 // #define NO_OS_DEPENDENCE

0068 
0069 // Define this to use features provided by Microsoft's CryptoAPI.

0070 // Currently the only feature used is Windows random number generation.

0071 // This macro will be ignored if NO_OS_DEPENDENCE is defined.

0072 // #define USE_MS_CRYPTOAPI

0073 
0074 // Define this to use features provided by Microsoft's CryptoNG API.

0075 // CryptoNG API is available in Vista and above and its cross platform,

0076 // including desktop apps and store apps. Currently the only feature

0077 // used is Windows random number generation.

0078 // This macro will be ignored if NO_OS_DEPENDENCE is defined.

0079 // #define USE_MS_CNGAPI

0080 
0081 // If the user did not make a choice, then select CryptoNG if

0082 // targeting Windows 8 or above.

0083 #if !defined(USE_MS_CRYPTOAPI) && !defined(USE_MS_CNGAPI)
0084 # if !defined(_USING_V110_SDK71_) && ((WINVER >= 0x0602 /*_WIN32_WINNT_WIN8*/) || \
0085      (_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/))
0086 #  define USE_MS_CNGAPI
0087 # else
0088 #  define USE_MS_CRYPTOAPI
0089 # endif
0090 #endif
0091 
0092 // Begin OS features, like init priorities and random numbers

0093 #ifndef NO_OS_DEPENDENCE
0094 
0095 // CRYPTOPP_INIT_PRIORITY attempts to manage initialization of C++ static objects.

0096 // Under GCC, the library uses init_priority attribute in the range

0097 // [CRYPTOPP_INIT_PRIORITY, CRYPTOPP_INIT_PRIORITY+100]. Under Windows,

0098 // CRYPTOPP_INIT_PRIORITY enlists "#pragma init_seg(lib)". The platforms

0099 // with gaps are Apple and Sun because they require linker scripts. Apple and

0100 // Sun will use the library's Singletons to initialize and acquire resources.

0101 // Also see http://cryptopp.com/wiki/Static_Initialization_Order_Fiasco

0102 #ifndef CRYPTOPP_INIT_PRIORITY
0103 # define CRYPTOPP_INIT_PRIORITY 250
0104 #endif
0105 
0106 // CRYPTOPP_USER_PRIORITY is for other libraries and user code that is using Crypto++

0107 // and managing C++ static object creation. It is guaranteed not to conflict with

0108 // values used by (or would be used by) the Crypto++ library.

0109 #ifndef CRYPTOPP_USER_PRIORITY
0110 # define CRYPTOPP_USER_PRIORITY (CRYPTOPP_INIT_PRIORITY+101)
0111 #endif
0112 
0113 // Most platforms allow us to specify when to create C++ objects. Apple and Sun do not.

0114 #if (CRYPTOPP_INIT_PRIORITY > 0) && !(defined(NO_OS_DEPENDENCE) || defined(__APPLE__) || defined(__sun__))
0115 # if (CRYPTOPP_GCC_VERSION >= 30000) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20900) || (_INTEL_COMPILER >= 800)
0116 #  define HAVE_GCC_INIT_PRIORITY 1
0117 # elif (CRYPTOPP_MSC_VERSION >= 1310)
0118 #  define HAVE_MSC_INIT_PRIORITY 1
0119 # elif defined(__xlc__) || defined(__xlC__) || defined(__ibmxl__)
0120 #  define HAVE_XLC_INIT_PRIORITY 1
0121 # endif
0122 #endif  // CRYPTOPP_INIT_PRIORITY, NO_OS_DEPENDENCE, Apple, Sun

0123 
0124 #if defined(CRYPTOPP_WIN32_AVAILABLE) || defined(CRYPTOPP_UNIX_AVAILABLE)
0125 #   define HIGHRES_TIMER_AVAILABLE
0126 #endif
0127 
0128 #ifdef CRYPTOPP_WIN32_AVAILABLE
0129 # if !defined(WINAPI_FAMILY)
0130 #   define THREAD_TIMER_AVAILABLE
0131 # elif defined(WINAPI_FAMILY)
0132 #   if (WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP))
0133 #     define THREAD_TIMER_AVAILABLE
0134 #  endif
0135 # endif
0136 #endif
0137 
0138 #if defined(CRYPTOPP_UNIX_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING)
0139 #   define NONBLOCKING_RNG_AVAILABLE
0140 #   define BLOCKING_RNG_AVAILABLE
0141 #   define OS_RNG_AVAILABLE
0142 #endif
0143 
0144 // Cygwin/Newlib requires _XOPEN_SOURCE=600

0145 #if defined(CRYPTOPP_UNIX_AVAILABLE)
0146 # define UNIX_SIGNALS_AVAILABLE 1
0147 #endif
0148 
0149 #ifdef CRYPTOPP_WIN32_AVAILABLE
0150 # if !defined(WINAPI_FAMILY)
0151 #   define NONBLOCKING_RNG_AVAILABLE
0152 #   define OS_RNG_AVAILABLE
0153 # elif defined(WINAPI_FAMILY)
0154 #   if (WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP))
0155 #     define NONBLOCKING_RNG_AVAILABLE
0156 #     define OS_RNG_AVAILABLE
0157 #   elif !(WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP))
0158 #     if ((WINVER >= 0x0A00 /*_WIN32_WINNT_WIN10*/) || (_WIN32_WINNT >= 0x0A00 /*_WIN32_WINNT_WIN10*/))
0159 #       define NONBLOCKING_RNG_AVAILABLE
0160 #       define OS_RNG_AVAILABLE
0161 #     endif
0162 #   endif
0163 # endif
0164 #endif
0165 
0166 #endif  // NO_OS_DEPENDENCE

0167 
0168 #endif  // CRYPTOPP_CONFIG_OS_H