Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

708 lines
27 KiB

  1. // config.h - written and placed in the public domain by Wei Dai
  2. //! \file config.h
  3. //! \brief Library configuration file
  4. #ifndef CRYPTOPP_CONFIG_H
  5. #define CRYPTOPP_CONFIG_H
  6. // ***************** Important Settings ********************
  7. // define this if running on a big-endian CPU
  8. #if !defined(IS_LITTLE_ENDIAN) && (defined(__BIG_ENDIAN__) || (defined(__s390__) || defined(__s390x__) || defined(__zarch__)) || defined(__sparc) || defined(__sparc__) || defined(__hppa__) || defined(__MIPSEB__) || defined(__ARMEB__) || (defined(__MWERKS__) && !defined(__INTEL__)))
  9. # define IS_BIG_ENDIAN
  10. #endif
  11. // define this if running on a little-endian CPU
  12. // big endian will be assumed if IS_LITTLE_ENDIAN is not defined
  13. #ifndef IS_BIG_ENDIAN
  14. # define IS_LITTLE_ENDIAN
  15. #endif
  16. // Sanity checks. Some processors have more than big-, little- and bi-endian modes. PDP mode, where order results in "4312", should
  17. // raise red flags immediately. Additionally, mis-classified machines, like (previosuly) S/390, should raise red flags immediately.
  18. #if defined(IS_BIG_ENDIAN) && defined(__GNUC__) && defined(__BYTE_ORDER__) && (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__)
  19. # error "IS_BIG_ENDIAN is set, but __BYTE_ORDER__ does not equal __ORDER_BIG_ENDIAN__"
  20. #endif
  21. #if defined(IS_LITTLE_ENDIAN) && defined(__GNUC__) && defined(__BYTE_ORDER__) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__)
  22. # error "IS_LITTLE_ENDIAN is set, but __BYTE_ORDER__ does not equal __ORDER_LITTLE_ENDIAN__"
  23. #endif
  24. // define this if you want to disable all OS-dependent features,
  25. // such as sockets and OS-provided random number generators
  26. // #define NO_OS_DEPENDENCE
  27. // Define this to use features provided by Microsoft's CryptoAPI.
  28. // Currently the only feature used is random number generation.
  29. // This macro will be ignored if NO_OS_DEPENDENCE is defined.
  30. #define USE_MS_CRYPTOAPI
  31. // Define this to ensure C/C++ standard compliance and respect for GCC aliasing rules and other alignment fodder. If you
  32. // experience a break with GCC at -O3, you should try this first. Guard it in case its set on the command line (and it differs).
  33. #ifndef CRYPTOPP_NO_UNALIGNED_DATA_ACCESS
  34. # define CRYPTOPP_NO_UNALIGNED_DATA_ACCESS
  35. #endif
  36. // ***************** Less Important Settings ***************
  37. // Library version
  38. #define CRYPTOPP_VERSION 563
  39. // define this to retain (as much as possible) old deprecated function and class names
  40. // #define CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
  41. // define this to retain (as much as possible) ABI and binary compatibility with Crypto++ 5.6.2.
  42. // Also see https://cryptopp.com/wiki/Config.h#Avoid_MAINTAIN_BACKWARDS_COMPATIBILITY
  43. #if (CRYPTOPP_VERSION <= 600)
  44. # if !defined(CRYPTOPP_NO_BACKWARDS_COMPATIBILITY_562) && !defined(CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562)
  45. // # define CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
  46. # endif
  47. #endif
  48. // Define this if you want or need the library's memcpy_s and memmove_s.
  49. // See http://github.com/weidai11/cryptopp/issues/28.
  50. // #if !defined(CRYPTOPP_WANT_SECURE_LIB)
  51. // # define CRYPTOPP_WANT_SECURE_LIB
  52. // #endif
  53. // File system code to write to GZIP archive.
  54. #if !defined(GZIP_OS_CODE)
  55. # define GZIP_OS_CODE 0
  56. #endif
  57. // Try this if your CPU has 256K internal cache or a slow multiply instruction
  58. // and you want a (possibly) faster IDEA implementation using log tables
  59. // #define IDEA_LARGECACHE
  60. // Define this if, for the linear congruential RNG, you want to use
  61. // the original constants as specified in S.K. Park and K.W. Miller's
  62. // CACM paper.
  63. // #define LCRNG_ORIGINAL_NUMBERS
  64. // choose which style of sockets to wrap (mostly useful for MinGW which has both)
  65. #if !defined(NO_BERKELEY_STYLE_SOCKETS) && !defined(PREFER_BERKELEY_STYLE_SOCKETS)
  66. # define PREFER_BERKELEY_STYLE_SOCKETS
  67. #endif
  68. // #if !defined(NO_WINDOWS_STYLE_SOCKETS) && !defined(PREFER_WINDOWS_STYLE_SOCKETS)
  69. // # define PREFER_WINDOWS_STYLE_SOCKETS
  70. // #endif
  71. // set the name of Rijndael cipher, was "Rijndael" before version 5.3
  72. #define CRYPTOPP_RIJNDAEL_NAME "AES"
  73. // CRYPTOPP_INIT_PRIORITY attempts to manage initialization of C++ static objects.
  74. // Under GCC, the library uses init_priority attribute in the range
  75. // [CRYPTOPP_INIT_PRIORITY, CRYPTOPP_INIT_PRIORITY+100]. Under Windows,
  76. // CRYPTOPP_INIT_PRIORITY enlists "#pragma init_seg(lib)".
  77. #define CRYPTOPP_INIT_PRIORITY 250
  78. // CRYPTOPP_USER_PRIORITY is for other libraries and user code that is using Crypto++
  79. // and managing C++ static object creation. It is guaranteed not to conflict with
  80. // values used by (or would be used by) the Crypto++ library.
  81. #if defined(CRYPTOPP_INIT_PRIORITY) && (CRYPTOPP_INIT_PRIORITY > 0)
  82. # define CRYPTOPP_USER_PRIORITY (CRYPTOPP_INIT_PRIORITY + 101)
  83. #else
  84. # define CRYPTOPP_USER_PRIORITY 250
  85. #endif
  86. // ***************** Important Settings Again ********************
  87. // But the defaults should be ok.
  88. // namespace support is now required
  89. #ifdef NO_NAMESPACE
  90. # error namespace support is now required
  91. #endif
  92. // Define this to workaround a Microsoft CryptoAPI bug where
  93. // each call to CryptAcquireContext causes a 100 KB memory leak.
  94. // Defining this will cause Crypto++ to make only one call to CryptAcquireContext.
  95. #define WORKAROUND_MS_BUG_Q258000
  96. #ifdef CRYPTOPP_DOXYGEN_PROCESSING
  97. // Document the namespce exists. Put it here before CryptoPP is undefined below.
  98. //! \namespace CryptoPP
  99. //! \brief Crypto++ library namespace
  100. //! \details Nearly all classes are located in the CryptoPP namespace. Within
  101. //! the namespace, there are two additional namespaces.
  102. //! <ul>
  103. //! <li>Name - namespace for names used with \p NameValuePairs and documented in argnames.h
  104. //! <li>Weak - namespace for weak and wounded algorithms, like ARC4, MD5 and Pananma
  105. //! </ul>
  106. namespace CryptoPP { }
  107. // Bring in the symbols fund in the weak namespace; and fold Weak1 into Weak
  108. # define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1
  109. # define Weak1 Weak
  110. // Avoid putting "CryptoPP::" in front of everything in Doxygen output
  111. # define CryptoPP
  112. # define NAMESPACE_BEGIN(x)
  113. # define NAMESPACE_END
  114. // Get Doxygen to generate better documentation for these typedefs
  115. # define DOCUMENTED_TYPEDEF(x, y) class y : public x {};
  116. // Make "protected" "private" so the functions and members are not documented
  117. # define protected private
  118. #else
  119. # define NAMESPACE_BEGIN(x) namespace x {
  120. # define NAMESPACE_END }
  121. # define DOCUMENTED_TYPEDEF(x, y) typedef x y;
  122. #endif
  123. #define ANONYMOUS_NAMESPACE_BEGIN namespace {
  124. #define ANONYMOUS_NAMESPACE_END }
  125. #define USING_NAMESPACE(x) using namespace x;
  126. #define DOCUMENTED_NAMESPACE_BEGIN(x) namespace x {
  127. #define DOCUMENTED_NAMESPACE_END }
  128. // What is the type of the third parameter to bind?
  129. // For Unix, the new standard is ::socklen_t (typically unsigned int), and the old standard is int.
  130. // Unfortunately there is no way to tell whether or not socklen_t is defined.
  131. // To work around this, TYPE_OF_SOCKLEN_T is a macro so that you can change it from the makefile.
  132. #ifndef TYPE_OF_SOCKLEN_T
  133. # if defined(_WIN32) || defined(__CYGWIN__)
  134. # define TYPE_OF_SOCKLEN_T int
  135. # else
  136. # define TYPE_OF_SOCKLEN_T ::socklen_t
  137. # endif
  138. #endif
  139. #if defined(__CYGWIN__) && defined(PREFER_WINDOWS_STYLE_SOCKETS)
  140. # define __USE_W32_SOCKETS
  141. #endif
  142. typedef unsigned char byte; // put in global namespace to avoid ambiguity with other byte typedefs
  143. NAMESPACE_BEGIN(CryptoPP)
  144. typedef unsigned short word16;
  145. typedef unsigned int word32;
  146. #if defined(_MSC_VER) || defined(__BORLANDC__)
  147. typedef unsigned __int64 word64;
  148. #define W64LIT(x) x##ui64
  149. #else
  150. typedef unsigned long long word64;
  151. #define W64LIT(x) x##ULL
  152. #endif
  153. // define large word type, used for file offsets and such
  154. typedef word64 lword;
  155. const lword LWORD_MAX = W64LIT(0xffffffffffffffff);
  156. #ifdef __GNUC__
  157. #define CRYPTOPP_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
  158. #endif
  159. // Apple and LLVM's Clang. Apple Clang version 7.0 roughly equals LLVM Clang version 3.7
  160. #if defined(__clang__ ) && !defined(__apple_build_version__)
  161. #define CRYPTOPP_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
  162. #elif defined(__clang__ ) && defined(__apple_build_version__)
  163. #define CRYPTOPP_APPLE_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
  164. #endif
  165. #ifdef _MSC_VER
  166. #define CRYPTOPP_MSC_VERSION (_MSC_VER)
  167. #endif
  168. // Need GCC 4.6/Clang 1.7/Apple Clang 2.0 or above due to "GCC diagnostic {push|pop}"
  169. #if (CRYPTOPP_GCC_VERSION >= 40600) || (CRYPTOPP_CLANG_VERSION >= 10700) || (CRYPTOPP_APPLE_CLANG_VERSION >= 20000)
  170. #define CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE 1
  171. #endif
  172. // Clang due to "Inline assembly operands don't work with .intel_syntax", http://llvm.org/bugs/show_bug.cgi?id=24232
  173. // TODO: supply the upper version when LLVM fixes it. We set it to 20.0 for compilation purposes.
  174. #if (defined(CRYPTOPP_CLANG_VERSION) && CRYPTOPP_CLANG_VERSION <= 200000) || (defined(CRYPTOPP_APPLE_CLANG_VERSION) && CRYPTOPP_APPLE_CLANG_VERSION <= 200000)
  175. #define CRYPTOPP_DISABLE_INTEL_ASM 1
  176. #endif
  177. // define hword, word, and dword. these are used for multiprecision integer arithmetic
  178. // Intel compiler won't have _umul128 until version 10.0. See http://softwarecommunity.intel.com/isn/Community/en-US/forums/thread/30231625.aspx
  179. #if (defined(_MSC_VER) && (!defined(__INTEL_COMPILER) || __INTEL_COMPILER >= 1000) && (defined(_M_X64) || defined(_M_IA64))) || (defined(__DECCXX) && defined(__alpha__)) || (defined(__INTEL_COMPILER) && (__INTEL_COMPILER < 1000) && defined(__x86_64__)) || (defined(__SUNPRO_CC) && defined(__x86_64__))
  180. typedef word32 hword;
  181. typedef word64 word;
  182. #else
  183. #define CRYPTOPP_NATIVE_DWORD_AVAILABLE
  184. #if defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || defined(__x86_64__) || defined(__mips64) || defined(__sparc64__)
  185. #if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !(CRYPTOPP_GCC_VERSION == 40001 && defined(__APPLE__)) && (CRYPTOPP_GCC_VERSION >= 30400)
  186. // GCC 4.0.1 on MacOS X is missing __umodti3 and __udivti3
  187. // mode(TI) division broken on amd64 with GCC earlier than GCC 3.4
  188. #define CRYPTOPP_WORD128_AVAILABLE
  189. typedef word32 hword;
  190. typedef word64 word;
  191. typedef __uint128_t dword;
  192. typedef __uint128_t word128;
  193. #elif defined(__GNUC__) && (__SIZEOF_INT128__ >= 16)
  194. // Detect availabliltiy of int128_t and uint128_t in preprocessor, http://gcc.gnu.org/ml/gcc-help/2015-08/msg00185.html.
  195. #define CRYPTOPP_WORD128_AVAILABLE
  196. typedef word32 hword;
  197. typedef word64 word;
  198. typedef __uint128_t dword;
  199. typedef __uint128_t word128;
  200. #else
  201. // if we're here, it means we're on a 64-bit CPU but we don't have a way to obtain 128-bit multiplication results
  202. typedef word16 hword;
  203. typedef word32 word;
  204. typedef word64 dword;
  205. #endif
  206. #elif defined(__GNUC__) && (__SIZEOF_INT128__ >= 16)
  207. // Detect availabliltiy of int128_t and uint128_t in preprocessor, http://gcc.gnu.org/ml/gcc-help/2015-08/msg00185.html.
  208. #define CRYPTOPP_WORD128_AVAILABLE
  209. typedef word32 hword;
  210. typedef word64 word;
  211. typedef __uint128_t dword;
  212. typedef __uint128_t word128;
  213. #else
  214. // being here means the native register size is probably 32 bits or less
  215. #define CRYPTOPP_BOOL_SLOW_WORD64 1
  216. typedef word16 hword;
  217. typedef word32 word;
  218. typedef word64 dword;
  219. #endif
  220. #endif
  221. #ifndef CRYPTOPP_BOOL_SLOW_WORD64
  222. #define CRYPTOPP_BOOL_SLOW_WORD64 0
  223. #endif
  224. // Produce a compiler error. It can be commented out, but you may not get the benefit of the fastest integers.
  225. #if (__SIZEOF_INT128__ >= 16) && !defined(CRYPTOPP_WORD128_AVAILABLE) && !defined(__aarch64__)
  226. # error "An int128_t and uint128_t are available, but CRYPTOPP_WORD128_AVAILABLE is not defined"
  227. #endif
  228. const unsigned int WORD_SIZE = sizeof(word);
  229. const unsigned int WORD_BITS = WORD_SIZE * 8;
  230. NAMESPACE_END
  231. #ifndef CRYPTOPP_L1_CACHE_LINE_SIZE
  232. // This should be a lower bound on the L1 cache line size. It's used for defense against timing attacks.
  233. // Also see http://stackoverflow.com/questions/794632/programmatically-get-the-cache-line-size.
  234. #if defined(_M_X64) || defined(__x86_64__) || (__ILP32__ >= 1)
  235. #define CRYPTOPP_L1_CACHE_LINE_SIZE 64
  236. #else
  237. // L1 cache line size is 32 on Pentium III and earlier
  238. #define CRYPTOPP_L1_CACHE_LINE_SIZE 32
  239. #endif
  240. #endif
  241. #if defined(_MSC_VER)
  242. #if _MSC_VER == 1200
  243. #include <malloc.h>
  244. #endif
  245. #if _MSC_VER > 1200 || defined(_mm_free)
  246. #define CRYPTOPP_MSVC6PP_OR_LATER // VC 6 processor pack or later
  247. #else
  248. #define CRYPTOPP_MSVC6_NO_PP // VC 6 without processor pack
  249. #endif
  250. #endif
  251. #ifndef CRYPTOPP_ALIGN_DATA
  252. #if defined(CRYPTOPP_MSVC6PP_OR_LATER)
  253. #define CRYPTOPP_ALIGN_DATA(x) __declspec(align(x))
  254. #elif defined(__GNUC__)
  255. #define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x)))
  256. #else
  257. #define CRYPTOPP_ALIGN_DATA(x)
  258. #endif
  259. #endif
  260. #ifndef CRYPTOPP_SECTION_ALIGN16
  261. #if defined(__GNUC__) && !defined(__APPLE__)
  262. // the alignment attribute doesn't seem to work without this section attribute when -fdata-sections is turned on
  263. #define CRYPTOPP_SECTION_ALIGN16 __attribute__((section ("CryptoPP_Align16")))
  264. #else
  265. #define CRYPTOPP_SECTION_ALIGN16
  266. #endif
  267. #endif
  268. #if defined(_MSC_VER) || defined(__fastcall)
  269. #define CRYPTOPP_FASTCALL __fastcall
  270. #else
  271. #define CRYPTOPP_FASTCALL
  272. #endif
  273. // VC60 workaround: it doesn't allow typename in some places
  274. #if defined(_MSC_VER) && (_MSC_VER < 1300)
  275. #define CPP_TYPENAME
  276. #else
  277. #define CPP_TYPENAME typename
  278. #endif
  279. // VC60 workaround: can't cast unsigned __int64 to float or double
  280. #if defined(_MSC_VER) && !defined(CRYPTOPP_MSVC6PP_OR_LATER)
  281. #define CRYPTOPP_VC6_INT64 (__int64)
  282. #else
  283. #define CRYPTOPP_VC6_INT64
  284. #endif
  285. #ifdef _MSC_VER
  286. #define CRYPTOPP_NO_VTABLE __declspec(novtable)
  287. #else
  288. #define CRYPTOPP_NO_VTABLE
  289. #endif
  290. #ifdef _MSC_VER
  291. // 4127: conditional expression is constant
  292. // 4231: nonstandard extension used : 'extern' before template explicit instantiation
  293. // 4250: dominance
  294. // 4251: member needs to have dll-interface
  295. // 4275: base needs to have dll-interface
  296. // 4505: unreferenced local function
  297. // 4512: assignment operator not generated
  298. // 4660: explicitly instantiating a class that's already implicitly instantiated
  299. // 4661: no suitable definition provided for explicit template instantiation request
  300. // 4786: identifer was truncated in debug information
  301. // 4355: 'this' : used in base member initializer list
  302. // 4910: '__declspec(dllexport)' and 'extern' are incompatible on an explicit instantiation
  303. # pragma warning(disable: 4127 4231 4250 4251 4275 4505 4512 4660 4661 4786 4355 4910)
  304. // Security related, possible defects
  305. // http://blogs.msdn.com/b/vcblog/archive/2010/12/14/off-by-default-compiler-warnings-in-visual-c.aspx
  306. # pragma warning(once: 4191 4242 4263 4264 4266 4302 4826 4905 4906 4928)
  307. #endif
  308. #ifdef __BORLANDC__
  309. // 8037: non-const function called for const object. needed to work around BCB2006 bug
  310. # pragma warn -8037
  311. #endif
  312. // [GCC Bug 53431] "C++ preprocessor ignores #pragma GCC diagnostic". Clang honors it.
  313. #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
  314. # pragma GCC diagnostic ignored "-Wunknown-pragmas"
  315. # pragma GCC diagnostic ignored "-Wunused-function"
  316. #endif
  317. #if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__MWERKS__) || defined(_STLPORT_VERSION)
  318. #define CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION
  319. #endif
  320. #ifndef CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION
  321. #define CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE
  322. #endif
  323. #ifdef CRYPTOPP_DISABLE_X86ASM // for backwards compatibility: this macro had both meanings
  324. #define CRYPTOPP_DISABLE_ASM
  325. #define CRYPTOPP_DISABLE_SSE2
  326. #endif
  327. // Apple's Clang prior to 5.0 cannot handle SSE2 (and Apple does not use LLVM Clang numbering...)
  328. #if defined(CRYPTOPP_APPLE_CLANG_VERSION) && (CRYPTOPP_APPLE_CLANG_VERSION < 50000)
  329. # define CRYPTOPP_DISABLE_ASM
  330. #endif
  331. #if !defined(CRYPTOPP_DISABLE_ASM) && ((defined(_MSC_VER) && defined(_M_IX86)) || (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))))
  332. // C++Builder 2010 does not allow "call label" where label is defined within inline assembly
  333. #define CRYPTOPP_X86_ASM_AVAILABLE
  334. #if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || CRYPTOPP_GCC_VERSION >= 30300 || defined(__SSE2__))
  335. #define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 1
  336. #else
  337. #define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 0
  338. #endif
  339. // SSE3 was actually introduced in GNU as 2.17, which was released 6/23/2006, but we can't tell what version of binutils is installed.
  340. // GCC 4.1.2 was released on 2/13/2007, so we'll use that as a proxy for the binutils version. Also see the output of
  341. // `gcc -dM -E -march=native - < /dev/null | grep -i SSE` for preprocessor defines available.
  342. #if !defined(CRYPTOPP_DISABLE_SSSE3) && (_MSC_VER >= 1400 || CRYPTOPP_GCC_VERSION >= 40102 || defined(__SSSE3__) || defined(__SSE3__))
  343. #define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 1
  344. #else
  345. #define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 0
  346. #endif
  347. #endif
  348. #if !defined(CRYPTOPP_DISABLE_ASM) && defined(_MSC_VER) && defined(_M_X64)
  349. #define CRYPTOPP_X64_MASM_AVAILABLE
  350. #endif
  351. #if !defined(CRYPTOPP_DISABLE_ASM) && defined(__GNUC__) && defined(__x86_64__)
  352. #define CRYPTOPP_X64_ASM_AVAILABLE
  353. #endif
  354. #if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || defined(__SSE2__))
  355. #define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 1
  356. #else
  357. #define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 0
  358. #endif
  359. #if !defined(CRYPTOPP_DISABLE_SSSE3) && !defined(CRYPTOPP_DISABLE_AESNI) && CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && (CRYPTOPP_GCC_VERSION >= 40400 || _MSC_FULL_VER >= 150030729 || __INTEL_COMPILER >= 1110 || defined(__AES__))
  360. #define CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE 1
  361. #else
  362. #define CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE 0
  363. #endif
  364. #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)
  365. #define CRYPTOPP_BOOL_ALIGN16 1
  366. #else
  367. #define CRYPTOPP_BOOL_ALIGN16 0
  368. #endif
  369. // how to allocate 16-byte aligned memory (for SSE2)
  370. #if defined(CRYPTOPP_MSVC6PP_OR_LATER)
  371. #define CRYPTOPP_MM_MALLOC_AVAILABLE
  372. #elif defined(__APPLE__)
  373. #define CRYPTOPP_APPLE_MALLOC_AVAILABLE
  374. #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
  375. #define CRYPTOPP_MALLOC_ALIGNMENT_IS_16
  376. #elif defined(__linux__) || defined(__sun__) || defined(__CYGWIN__)
  377. #define CRYPTOPP_MEMALIGN_AVAILABLE
  378. #else
  379. #define CRYPTOPP_NO_ALIGNED_ALLOC
  380. #endif
  381. // Apple always provides 16-byte aligned, and tells us to use calloc
  382. // http://developer.apple.com/library/mac/documentation/Performance/Conceptual/ManagingMemory/Articles/MemoryAlloc.html
  383. // how to disable inlining
  384. #if defined(_MSC_VER) && _MSC_VER >= 1300
  385. # define CRYPTOPP_NOINLINE_DOTDOTDOT
  386. # define CRYPTOPP_NOINLINE __declspec(noinline)
  387. #elif defined(__GNUC__)
  388. # define CRYPTOPP_NOINLINE_DOTDOTDOT
  389. # define CRYPTOPP_NOINLINE __attribute__((noinline))
  390. #else
  391. # define CRYPTOPP_NOINLINE_DOTDOTDOT ...
  392. # define CRYPTOPP_NOINLINE
  393. #endif
  394. // how to declare class constants
  395. #if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__INTEL_COMPILER)
  396. # define CRYPTOPP_CONSTANT(x) enum {x};
  397. #else
  398. # define CRYPTOPP_CONSTANT(x) static const int x;
  399. #endif
  400. // Linux provides X32, which is 32-bit integers, longs and pointers on x86_64 using the full x86_64 register set.
  401. // Detect via __ILP32__ (http://wiki.debian.org/X32Port). Both GCC and Clang provide the preprocessor macro.
  402. #if ((__ILP32__ >= 1) || (_ILP32 >= 1))
  403. #define CRYPTOPP_BOOL_X32 1
  404. #else
  405. #define CRYPTOPP_BOOL_X32 0
  406. #endif
  407. // see http://predef.sourceforge.net/prearch.html
  408. #if (defined(_M_IX86) || defined(__i386__) || defined(__i386) || defined(_X86_) || defined(__I86__) || defined(__INTEL__)) && !CRYPTOPP_BOOL_X32
  409. #define CRYPTOPP_BOOL_X86 1
  410. #else
  411. #define CRYPTOPP_BOOL_X86 0
  412. #endif
  413. #if (defined(_M_X64) || defined(__x86_64__)) && !CRYPTOPP_BOOL_X32
  414. #define CRYPTOPP_BOOL_X64 1
  415. #else
  416. #define CRYPTOPP_BOOL_X64 0
  417. #endif
  418. // Undo the ASM and Intrinsic related defines due to X32.
  419. #if CRYPTOPP_BOOL_X32
  420. # undef CRYPTOPP_BOOL_X64
  421. # undef CRYPTOPP_X64_ASM_AVAILABLE
  422. # undef CRYPTOPP_X64_MASM_AVAILABLE
  423. #endif
  424. #if !defined(CRYPTOPP_NO_UNALIGNED_DATA_ACCESS) && !defined(CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS)
  425. #if (CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || defined(__powerpc__) || (__ARM_FEATURE_UNALIGNED >= 1))
  426. #define CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS
  427. #endif
  428. #endif
  429. // ***************** determine availability of OS features ********************
  430. #ifndef NO_OS_DEPENDENCE
  431. #if defined(_WIN32) || defined(__CYGWIN__)
  432. #define CRYPTOPP_WIN32_AVAILABLE
  433. #endif
  434. #if defined(__unix__) || defined(__MACH__) || defined(__NetBSD__) || defined(__sun)
  435. #define CRYPTOPP_UNIX_AVAILABLE
  436. #endif
  437. #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
  438. #define CRYPTOPP_BSD_AVAILABLE
  439. #endif
  440. #if defined(CRYPTOPP_WIN32_AVAILABLE) || defined(CRYPTOPP_UNIX_AVAILABLE)
  441. # define HIGHRES_TIMER_AVAILABLE
  442. #endif
  443. #ifdef CRYPTOPP_UNIX_AVAILABLE
  444. # define HAS_BERKELEY_STYLE_SOCKETS
  445. #endif
  446. #ifdef CRYPTOPP_WIN32_AVAILABLE
  447. # define HAS_WINDOWS_STYLE_SOCKETS
  448. #endif
  449. #if defined(HIGHRES_TIMER_AVAILABLE) && (defined(HAS_BERKELEY_STYLE_SOCKETS) || defined(HAS_WINDOWS_STYLE_SOCKETS))
  450. # define SOCKETS_AVAILABLE
  451. #endif
  452. #if defined(HAS_WINDOWS_STYLE_SOCKETS) && (!defined(HAS_BERKELEY_STYLE_SOCKETS) || defined(PREFER_WINDOWS_STYLE_SOCKETS))
  453. # define USE_WINDOWS_STYLE_SOCKETS
  454. #else
  455. # define USE_BERKELEY_STYLE_SOCKETS
  456. #endif
  457. #if defined(HIGHRES_TIMER_AVAILABLE) && defined(CRYPTOPP_WIN32_AVAILABLE) && !defined(USE_BERKELEY_STYLE_SOCKETS)
  458. # define WINDOWS_PIPES_AVAILABLE
  459. #endif
  460. #if defined(CRYPTOPP_WIN32_AVAILABLE) && defined(USE_MS_CRYPTOAPI)
  461. # define NONBLOCKING_RNG_AVAILABLE
  462. # define OS_RNG_AVAILABLE
  463. #endif
  464. #if defined(CRYPTOPP_UNIX_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING)
  465. # define NONBLOCKING_RNG_AVAILABLE
  466. # define BLOCKING_RNG_AVAILABLE
  467. # define OS_RNG_AVAILABLE
  468. # define HAS_PTHREADS
  469. # define THREADS_AVAILABLE
  470. #endif
  471. #ifdef CRYPTOPP_WIN32_AVAILABLE
  472. # define HAS_WINTHREADS
  473. # define THREADS_AVAILABLE
  474. #endif
  475. #endif // NO_OS_DEPENDENCE
  476. // ***************** DLL related ********************
  477. #if defined(CRYPTOPP_WIN32_AVAILABLE) && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
  478. #ifdef CRYPTOPP_EXPORTS
  479. #define CRYPTOPP_IS_DLL
  480. #define CRYPTOPP_DLL __declspec(dllexport)
  481. #elif defined(CRYPTOPP_IMPORTS)
  482. #define CRYPTOPP_IS_DLL
  483. #define CRYPTOPP_DLL __declspec(dllimport)
  484. #else
  485. #define CRYPTOPP_DLL
  486. #endif
  487. #define CRYPTOPP_API __cdecl
  488. #else // not CRYPTOPP_WIN32_AVAILABLE
  489. #define CRYPTOPP_DLL
  490. #define CRYPTOPP_API
  491. #endif // CRYPTOPP_WIN32_AVAILABLE
  492. #if defined(__MWERKS__)
  493. #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern class CRYPTOPP_DLL
  494. #elif defined(__BORLANDC__) || defined(__SUNPRO_CC)
  495. #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL
  496. #else
  497. #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern template class CRYPTOPP_DLL
  498. #endif
  499. #if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_IMPORTS)
  500. #define CRYPTOPP_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL
  501. #else
  502. #define CRYPTOPP_DLL_TEMPLATE_CLASS CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS
  503. #endif
  504. #if defined(__MWERKS__)
  505. #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern class
  506. #elif defined(__BORLANDC__) || defined(__SUNPRO_CC)
  507. #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS template class
  508. #else
  509. #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern template class
  510. #endif
  511. #if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_EXPORTS)
  512. #define CRYPTOPP_STATIC_TEMPLATE_CLASS template class
  513. #else
  514. #define CRYPTOPP_STATIC_TEMPLATE_CLASS CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS
  515. #endif
  516. // ************** Unused variable ***************
  517. // Portable way to suppress warnings.
  518. // Moved from misc.h due to circular depenedencies.
  519. #define CRYPTOPP_UNUSED(x) ((void)x)
  520. // ***************** C++11 related ********************
  521. // Visual Studio began at VS2010, http://msdn.microsoft.com/en-us/library/hh567368%28v=vs.110%29.aspx.
  522. // Intel and C++11 language features, http://software.intel.com/en-us/articles/c0x-features-supported-by-intel-c-compiler
  523. // GCC and C++11 language features, http://gcc.gnu.org/projects/cxx0x.html
  524. // Clang and C++11 language features, http://clang.llvm.org/cxx_status.html
  525. #if (_MSC_VER >= 1600) || (__cplusplus >= 201103L)
  526. # define CRYPTOPP_CXX11 1
  527. #endif
  528. // Hack ahead. Apple's standard library does not have C++'s unique_ptr in C++11. We can't
  529. // test for unique_ptr directly because some of the non-Apple Clangs on OS X fail the same
  530. // way. However, modern standard libraries have <forward_list>, so we test for it instead.
  531. // Thanks to Jonathan Wakely for devising the clever test for modern/ancient versions.
  532. // TODO: test under Xcode 3, where g++ is really g++.
  533. #if defined(__APPLE__) && defined(__clang__)
  534. # if !(defined(__has_include) && __has_include(<forward_list>))
  535. # undef CRYPTOPP_CXX11
  536. # endif
  537. #endif
  538. // C++11 or C++14 is available
  539. #if defined(CRYPTOPP_CXX11)
  540. // alignof/alignas: MS at VS2013 (19.00); GCC at 4.8; Clang at 3.3; and Intel 15.0.
  541. #if (CRYPTOPP_MSC_VERSION >= 1900)
  542. # define CRYPTOPP_CXX11_ALIGNAS 1
  543. # define CRYPTOPP_CXX11_ALIGNOF 1
  544. #elif defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1500)
  545. # define CRYPTOPP_CXX11_ALIGNAS 1
  546. # define CRYPTOPP_CXX11_ALIGNOF 1
  547. #elif defined(__clang__)
  548. # if __has_feature(cxx_alignof)
  549. # define CRYPTOPP_CXX11_ALIGNAS 1
  550. # define CRYPTOPP_CXX11_ALIGNOF 1
  551. # endif
  552. #elif (CRYPTOPP_GCC_VERSION >= 40800)
  553. # define CRYPTOPP_CXX11_ALIGNAS 1
  554. # define CRYPTOPP_CXX11_ALIGNOF 1
  555. #endif // alignof/alignas
  556. // noexcept: MS at VS2015 (19.00); GCC at 4.6; Clang at 3.0; and Intel 14.0.
  557. #if (CRYPTOPP_MSC_VERSION >= 1900)
  558. # define CRYPTOPP_CXX11_NOEXCEPT 1
  559. #elif defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1400)
  560. # define CRYPTOPP_CXX11_NOEXCEPT 1
  561. #elif defined(__clang__)
  562. # if __has_feature(cxx_noexcept)
  563. # define CRYPTOPP_CXX11_NOEXCEPT 1
  564. # endif
  565. #elif (CRYPTOPP_GCC_VERSION >= 40600)
  566. # define CRYPTOPP_CXX11_NOEXCEPT 1
  567. #endif // noexcept compilers
  568. // variadic templates: MS at VS2013 (18.00); GCC at 4.3; Clang at 2.9; and Intel 12.1.
  569. #if (CRYPTOPP_MSC_VERSION >= 1800)
  570. # define CRYPTOPP_CXX11_VARIADIC_TEMPLATES 1
  571. #elif defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1210)
  572. # define CRYPTOPP_CXX11_VARIADIC_TEMPLATES 1
  573. #elif defined(__clang__)
  574. # if __has_feature(cxx_variadic_templates)
  575. # define CRYPTOPP_CXX11_VARIADIC_TEMPLATES 1
  576. # endif
  577. #elif (CRYPTOPP_GCC_VERSION >= 40300)
  578. # define CRYPTOPP_CXX11_VARIADIC_TEMPLATES 1
  579. #endif // variadic templates
  580. // TODO: Emplacement, R-values and Move semantics
  581. // Needed because we are catching warnings with GCC and MSC
  582. #endif // CRYPTOPP_CXX11
  583. #if defined(CRYPTOPP_CXX11_NOEXCEPT)
  584. # define CRYPTOPP_THROW noexcept(false)
  585. # define CRYPTOPP_NO_THROW noexcept(true)
  586. #else
  587. # define CRYPTOPP_THROW
  588. # define CRYPTOPP_NO_THROW
  589. #endif // CRYPTOPP_CXX11_NOEXCEPT
  590. // OK to comment the following out, but please report it so we can fix it.
  591. #if (defined(__cplusplus) && (__cplusplus >= 199711L)) && !defined(CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE)
  592. # error "std::uncaught_exception is not available. This is likely a configuration error."
  593. #endif
  594. #endif