104
104
typedef unsigned short word16;
105
105
typedef unsigned int word32;
107
#if defined(__GNUC__) || defined(__MWERKS__)
107
#if defined(__GNUC__) || defined(__MWERKS__) || defined(__SUNPRO_CC)
108
108
#define WORD64_AVAILABLE
109
109
typedef unsigned long long word64;
110
110
#define W64LIT(x) x##LL
111
#elif defined(_MSC_VER) || defined(__BCPLUSPLUS__)
111
#elif defined(_MSC_VER) || defined(__BORLANDC__)
112
112
#define WORD64_AVAILABLE
113
113
typedef unsigned __int64 word64;
114
114
#define W64LIT(x) x##ui64
117
// define largest word type
117
// define large word type, used for file offsets and such
118
118
#ifdef WORD64_AVAILABLE
119
119
typedef word64 lword;
120
120
const lword LWORD_MAX = W64LIT(0)-1;
123
123
const lword LWORD_MAX = lword(0)-1;
126
#if defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || defined(__x86_64__) || defined(__mips64) || defined(_M_X64)
127
// These platforms have 64-bit CPU registers. Unfortunately most C++ compilers doesn't
128
// allow any way to access the 64-bit by 64-bit multiply instruction without using
129
// assembly, so in order to use word64 as word, the assembly instruction must be defined
130
// in Dword::Multiply().
126
// define hword, word, and dword. these are used for multiprecision integer arithmetic
127
// Intel compiler won't have _umul128 until version 10.0. See http://softwarecommunity.intel.com/isn/Community/en-US/forums/thread/30231625.aspx
128
#if (defined(_MSC_VER) && (!defined(__INTEL_COMPILER) || __INTEL_COMPILER >= 1000) && (defined(_M_X64) || defined(_M_IA64))) || (defined(__DECCXX) && defined(__alpha__))
131
129
typedef word32 hword;
132
130
typedef word64 word;
134
132
#define CRYPTOPP_NATIVE_DWORD_AVAILABLE
135
#ifdef WORD64_AVAILABLE
136
#define CRYPTOPP_SLOW_WORD64 // defined this if your CPU is not 64-bit to use alternative code that avoids word64
133
#if defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || defined(__x86_64__) || defined(__mips64) || defined(__sparc64__)
134
#if defined(__GNUC__)
135
typedef word32 hword;
137
typedef __uint128_t dword;
138
typedef __uint128_t word128;
139
#define CRYPTOPP_WORD128_AVAILABLE
141
// 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
142
typedef word16 hword;
144
typedef word64 dword;
146
#elif defined(WORD64_AVAILABLE)
147
#define CRYPTOPP_SLOW_WORD64 // use alternative code that avoids word64
137
148
typedef word16 hword;
138
149
typedef word32 word;
139
150
typedef word64 dword;
142
153
typedef word16 word;
143
154
typedef word32 dword;
147
158
const unsigned int WORD_SIZE = sizeof(word);
148
159
const unsigned int WORD_BITS = WORD_SIZE * 8;
150
#if defined(_MSC_VER) || defined(__BCPLUSPLUS__)
151
#define INTEL_INTRINSICS
153
#elif defined(__MWERKS__) && TARGET_CPU_PPC
154
#define PPC_INTRINSICS
156
#elif defined(__GNUC__) && defined(__i386__)
157
// GCC does peephole optimizations which should result in using rotate instructions
161
163
#ifndef CRYPTOPP_L1_CACHE_LINE_SIZE
162
164
// This should be a lower bound on the L1 cache line size. It's used for defense against timing attacks.
163
// L1 cache line size is 32 on Pentium III and earlier
164
#define CRYPTOPP_L1_CACHE_LINE_SIZE 32
167
#ifndef CRYPTOPP_L1_CACHE_ALIGN
169
#define CRYPTOPP_L1_CACHE_ALIGN(x) __declspec(align(CRYPTOPP_L1_CACHE_LINE_SIZE)) x
170
#elif defined(__GNUC__)
171
#define CRYPTOPP_L1_CACHE_ALIGN(x) x __attribute__((aligned(CRYPTOPP_L1_CACHE_LINE_SIZE)))
165
#if defined(_M_X64) || defined(__x86_64__)
166
#define CRYPTOPP_L1_CACHE_LINE_SIZE 64
168
// L1 cache line size is 32 on Pentium III and earlier
169
#define CRYPTOPP_L1_CACHE_LINE_SIZE 32
173
#if defined(_MSC_VER)
177
#if _MSC_VER > 1200 || defined(_mm_free)
178
#define CRYPTOPP_MSVC6PP_OR_LATER // VC 6 processor pack or later
180
#define CRYPTOPP_MSVC6_NO_PP // VC 6 without processor pack
185
#define CRYPTOPP_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
188
#ifndef CRYPTOPP_ALIGN_DATA
189
#if defined(CRYPTOPP_MSVC6PP_OR_LATER)
190
#define CRYPTOPP_ALIGN_DATA(x) __declspec(align(x))
191
#elif defined(__GNUC__) || __SUNPRO_CC > 0x580
192
#define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x)))
194
#define CRYPTOPP_ALIGN_DATA(x)
198
#ifndef CRYPTOPP_SECTION_ALIGN16
200
// the alignment attribute doesn't seem to work without this section attribute when -fdata-sections is turned on
201
#define CRYPTOPP_SECTION_ALIGN16 __attribute__((section ("CryptoPP_Align16")))
203
#define CRYPTOPP_SECTION_ALIGN16
207
#if defined(_MSC_VER) || defined(__fastcall)
208
#define CRYPTOPP_FASTCALL __fastcall
210
#define CRYPTOPP_FASTCALL
177
213
// VC60 workaround: it doesn't allow typename in some places
178
214
#if defined(_MSC_VER) && (_MSC_VER < 1300)
207
255
#define CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE
258
#ifdef CRYPTOPP_DISABLE_X86ASM // for backwards compatibility: this macro had both meanings
259
#define CRYPTOPP_DISABLE_ASM
260
#define CRYPTOPP_DISABLE_SSE2
210
263
// CodeWarrior defines _MSC_VER
211
#if !defined(CRYPTOPP_DISABLE_X86ASM) && ((defined(_MSC_VER) && !defined(__MWERKS__) && defined(_M_IX86)) || (defined(__GNUC__) && defined(__i386__)))
212
#define CRYPTOPP_X86ASM_AVAILABLE
264
#if !defined(CRYPTOPP_DISABLE_ASM) && ((defined(_MSC_VER) && !defined(__MWERKS__) && defined(_M_IX86)) || (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))))
265
#define CRYPTOPP_X86_ASM_AVAILABLE
267
#if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || CRYPTOPP_GCC_VERSION >= 30300)
268
#define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 1
270
#define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 0
273
// SSSE3 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.
274
// GCC 4.1.2 was released on 2/13/2007, so we'll use that as a proxy for the binutils version.
275
#if !defined(CRYPTOPP_DISABLE_SSSE3) && (_MSC_VER >= 1400 || CRYPTOPP_GCC_VERSION >= 40102)
276
#define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 1
278
#define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 0
282
#if !defined(CRYPTOPP_DISABLE_ASM) && defined(_MSC_VER) && defined(_M_X64)
283
#define CRYPTOPP_X64_MASM_AVAILABLE
286
#if !defined(CRYPTOPP_DISABLE_ASM) && defined(__GNUC__) && defined(__x86_64__)
287
#define CRYPTOPP_X64_ASM_AVAILABLE
290
#if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || defined(__SSE2__))
291
#define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 1
293
#define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 0
296
// how to allocate 16-byte aligned memory (for SSE2)
297
#if defined(CRYPTOPP_MSVC6PP_OR_LATER)
298
#define CRYPTOPP_MM_MALLOC_AVAILABLE
299
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
300
#define CRYPTOPP_MALLOC_ALIGNMENT_IS_16
301
#elif defined(__linux__) || defined(__sun__) || defined(__CYGWIN__)
302
#define CRYPTOPP_MEMALIGN_AVAILABLE
303
#elif defined(__MINGW32__)
305
#define _mm_malloc(a, b) __mingw_aligned_malloc(a, b)
306
#define _mm_free(a) __mingw_aligned_free(a)
308
#define CRYPTOPP_MM_MALLOC_AVAILABLE
310
#define CRYPTOPP_NO_ALIGNED_ALLOC
313
// how to disable inlining
314
#if defined(_MSC_VER) && _MSC_VER >= 1300
315
# define CRYPTOPP_NOINLINE_DOTDOTDOT
316
# define CRYPTOPP_NOINLINE __declspec(noinline)
317
#elif defined(__GNUC__)
318
# define CRYPTOPP_NOINLINE_DOTDOTDOT
319
# define CRYPTOPP_NOINLINE __attribute__((noinline))
321
# define CRYPTOPP_NOINLINE_DOTDOTDOT ...
322
# define CRYPTOPP_NOINLINE
325
// how to declare class constants
326
#if defined(_MSC_VER) && _MSC_VER <= 1300
327
# define CRYPTOPP_CONSTANT(x) enum {x};
329
# define CRYPTOPP_CONSTANT(x) static const int x;
332
#if defined(_M_X64) || defined(__x86_64__)
333
#define CRYPTOPP_BOOL_X64 1
335
#define CRYPTOPP_BOOL_X64 0
338
// see http://predef.sourceforge.net/prearch.html
339
#if defined(_M_IX86) || defined(__i386__) || defined(__i386) || defined(_X86_) || defined(__I86__) || defined(__INTEL__)
340
#define CRYPTOPP_BOOL_X86 1
342
#define CRYPTOPP_BOOL_X86 0
345
#if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X86
346
#define CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS
215
349
// ***************** determine availability of OS features ********************