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

config_int.h
Go to the documentation of this file.
1 // config_int.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_int.h
6 /// \brief Library configuration file
7 /// \details <tt>config.h</tt> was split into components in May 2019 to better
8 /// integrate with Autoconf and its feature tests. The splitting occurred so
9 /// users could continue to include <tt>config.h</tt> while allowing Autoconf
10 /// to write new <tt>config_asm.h</tt> and new <tt>config_cxx.h</tt> using
11 /// its feature tests.
12 /// \sa <A HREF="https://github.com/weidai11/cryptopp/issues/835">Issue 835</A>
13 /// \since Crypto++ 8.3
14
15 #ifndef CRYPTOPP_CONFIG_INT_H
16 #define CRYPTOPP_CONFIG_INT_H
17
18 #include "config_ns.h"
19 #include "config_ver.h"
20
21 // Originally in global namespace to avoid ambiguity with other byte typedefs.
22 // Moved to Crypto++ namespace due to C++17, std::byte and potential compile
23 // problems. Also see http://www.cryptopp.com/wiki/std::byte and
24 // http://github.com/weidai11/cryptopp/issues/442.
25 // typedef unsigned char byte;
26 #define CRYPTOPP_NO_GLOBAL_BYTE 1
27
28 NAMESPACE_BEGIN(CryptoPP)
29
30 // Signed words added at Issue 609 for early versions of and Visual Studio and
31 // the NaCl gear. Also see https://github.com/weidai11/cryptopp/issues/609.
32
33 typedef unsigned char byte;
34 typedef unsigned short word16;
35 typedef unsigned int word32;
36
37 typedef signed char sbyte;
38 typedef signed short sword16;
39 typedef signed int sword32;
40
41 #if defined(_MSC_VER) || defined(__BORLANDC__)
42 typedef signed __int64 sword64;
43 typedef unsigned __int64 word64;
44 #define SW64LIT(x) x##i64
45 #define W64LIT(x) x##ui64
46 #elif (_LP64 || __LP64__)
47 typedef signed long sword64;
48 typedef unsigned long word64;
49 #define SW64LIT(x) x##L
50 #define W64LIT(x) x##UL
51 #else
52 typedef signed long long sword64;
53 typedef unsigned long long word64;
54 #define SW64LIT(x) x##LL
55 #define W64LIT(x) x##ULL
56 #endif
57
58 // define large word type, used for file offsets and such
59 typedef word64 lword;
60 const lword LWORD_MAX = W64LIT(0xffffffffffffffff);
61
62 // define hword, word, and dword. these are used for multiprecision integer arithmetic
63 // Intel compiler won't have _umul128 until version 10.0. See http://softwarecommunity.intel.com/isn/Community/en-US/forums/thread/30231625.aspx
64 #if (defined(_MSC_VER) && (!defined(__INTEL_COMPILER) || __INTEL_COMPILER >= 1000) && (defined(_M_X64) || defined(_M_IA64))) || (defined(__DECCXX) && defined(__alpha__)) || (defined(__INTEL_COMPILER) && defined(__x86_64__)) || (defined(__SUNPRO_CC) && defined(__x86_64__))
65 typedef word32 hword;
66 typedef word64 word;
67 #else
68 #define CRYPTOPP_NATIVE_DWORD_AVAILABLE 1
69 #if defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || defined(__x86_64__) || defined(__mips64) || defined(__sparc64__) || defined(__aarch64__)
70 #if ((CRYPTOPP_GCC_VERSION >= 30400) || (CRYPTOPP_LLVM_CLANG_VERSION >= 30000) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40300)) && (__SIZEOF_INT128__ >= 16)
71 // GCC 4.0.1 on MacOS X is missing __umodti3 and __udivti3
72 // GCC 4.8.3 and bad uint128_t ops on PPC64/POWER7 (Issue 421)
73 // mode(TI) division broken on amd64 with GCC earlier than GCC 3.4
74 typedef word32 hword;
75 typedef word64 word;
76 typedef __uint128_t dword;
77 typedef __uint128_t word128;
78 #define CRYPTOPP_WORD128_AVAILABLE 1
79 #else
80 // 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
81 typedef word16 hword;
82 typedef word32 word;
83 typedef word64 dword;
84 #endif
85 #else
86 // being here means the native register size is probably 32 bits or less
87 #define CRYPTOPP_BOOL_SLOW_WORD64 1
88 typedef word16 hword;
89 typedef word32 word;
90 typedef word64 dword;
91 #endif
92 #endif
93
94 #ifndef CRYPTOPP_BOOL_SLOW_WORD64
95 # define CRYPTOPP_BOOL_SLOW_WORD64 0
96 #endif
97
98 const unsigned int WORD_SIZE = sizeof(word);
99 const unsigned int WORD_BITS = WORD_SIZE * 8;
100
101 NAMESPACE_END
102
103 #endif // CRYPTOPP_CONFIG_INT_H
config_ns.h
Library configuration file.
CryptoPP
Crypto++ library namespace.
config_ver.h
Library configuration file.