Repeatedly resetting the timestamp for seed nodes in the database was slow. Only...
[bitcoinplatinum.git] / cryptopp / config.h
blob0737027f41f37e3946c8eff124dac70ca11c818d
1 #ifndef CRYPTOPP_CONFIG_H
2 #define CRYPTOPP_CONFIG_H
4 //// Bitcoin: disable SSE2 on 32-bit
5 #if !defined(_M_X64) && !defined(__x86_64__)
6 #define CRYPTOPP_DISABLE_SSE2 1
7 #endif
8 //////////// end of Bitcoin changes
11 // ***************** Important Settings ********************
13 // define this if running on a big-endian CPU
14 #if !defined(IS_LITTLE_ENDIAN) && (defined(__BIG_ENDIAN__) || defined(__sparc) || defined(__sparc__) || defined(__hppa__) || defined(__mips__) || (defined(__MWERKS__) && !defined(__INTEL__)))
15 # define IS_BIG_ENDIAN
16 #endif
18 // define this if running on a little-endian CPU
19 // big endian will be assumed if IS_LITTLE_ENDIAN is not defined
20 #ifndef IS_BIG_ENDIAN
21 # define IS_LITTLE_ENDIAN
22 #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
28 // Define this to use features provided by Microsoft's CryptoAPI.
29 // Currently the only feature used is random number generation.
30 // This macro will be ignored if NO_OS_DEPENDENCE is defined.
31 #define USE_MS_CRYPTOAPI
33 // Define this to 1 to enforce the requirement in FIPS 186-2 Change Notice 1 that only 1024 bit moduli be used
34 #ifndef DSA_1024_BIT_MODULUS_ONLY
35 # define DSA_1024_BIT_MODULUS_ONLY 1
36 #endif
38 // ***************** Less Important Settings ***************
40 // define this to retain (as much as possible) old deprecated function and class names
41 // #define CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
43 #define GZIP_OS_CODE 0
45 // Try this if your CPU has 256K internal cache or a slow multiply instruction
46 // and you want a (possibly) faster IDEA implementation using log tables
47 // #define IDEA_LARGECACHE
49 // Define this if, for the linear congruential RNG, you want to use
50 // the original constants as specified in S.K. Park and K.W. Miller's
51 // CACM paper.
52 // #define LCRNG_ORIGINAL_NUMBERS
54 // choose which style of sockets to wrap (mostly useful for cygwin which has both)
55 #define PREFER_BERKELEY_STYLE_SOCKETS
56 // #define PREFER_WINDOWS_STYLE_SOCKETS
58 // set the name of Rijndael cipher, was "Rijndael" before version 5.3
59 #define CRYPTOPP_RIJNDAEL_NAME "AES"
61 // ***************** Important Settings Again ********************
62 // But the defaults should be ok.
64 // namespace support is now required
65 #ifdef NO_NAMESPACE
66 # error namespace support is now required
67 #endif
69 // Define this to workaround a Microsoft CryptoAPI bug where
70 // each call to CryptAcquireContext causes a 100 KB memory leak.
71 // Defining this will cause Crypto++ to make only one call to CryptAcquireContext.
72 #define WORKAROUND_MS_BUG_Q258000
74 #ifdef CRYPTOPP_DOXYGEN_PROCESSING
75 // Avoid putting "CryptoPP::" in front of everything in Doxygen output
76 # define CryptoPP
77 # define NAMESPACE_BEGIN(x)
78 # define NAMESPACE_END
79 // Get Doxygen to generate better documentation for these typedefs
80 # define DOCUMENTED_TYPEDEF(x, y) class y : public x {};
81 #else
82 # define NAMESPACE_BEGIN(x) namespace x {
83 # define NAMESPACE_END }
84 # define DOCUMENTED_TYPEDEF(x, y) typedef x y;
85 #endif
86 #define ANONYMOUS_NAMESPACE_BEGIN namespace {
87 #define USING_NAMESPACE(x) using namespace x;
88 #define DOCUMENTED_NAMESPACE_BEGIN(x) namespace x {
89 #define DOCUMENTED_NAMESPACE_END }
91 // What is the type of the third parameter to bind?
92 // For Unix, the new standard is ::socklen_t (typically unsigned int), and the old standard is int.
93 // Unfortunately there is no way to tell whether or not socklen_t is defined.
94 // To work around this, TYPE_OF_SOCKLEN_T is a macro so that you can change it from the makefile.
95 #ifndef TYPE_OF_SOCKLEN_T
96 # if defined(_WIN32) || defined(__CYGWIN__)
97 # define TYPE_OF_SOCKLEN_T int
98 # else
99 # define TYPE_OF_SOCKLEN_T ::socklen_t
100 # endif
101 #endif
103 #if defined(__CYGWIN__) && defined(PREFER_WINDOWS_STYLE_SOCKETS)
104 # define __USE_W32_SOCKETS
105 #endif
107 typedef unsigned char byte; // put in global namespace to avoid ambiguity with other byte typedefs
109 NAMESPACE_BEGIN(CryptoPP)
111 typedef unsigned short word16;
112 typedef unsigned int word32;
114 #if defined(_MSC_VER) || defined(__BORLANDC__)
115 typedef unsigned __int64 word64;
116 #define W64LIT(x) x##ui64
117 #else
118 typedef unsigned long long word64;
119 #define W64LIT(x) x##ULL
120 #endif
122 // define large word type, used for file offsets and such
123 typedef word64 lword;
124 const lword LWORD_MAX = W64LIT(0xffffffffffffffff);
126 #ifdef __GNUC__
127 #define CRYPTOPP_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
128 #endif
130 // define hword, word, and dword. these are used for multiprecision integer arithmetic
131 // Intel compiler won't have _umul128 until version 10.0. See http://softwarecommunity.intel.com/isn/Community/en-US/forums/thread/30231625.aspx
132 #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__))
133 typedef word32 hword;
134 typedef word64 word;
135 #else
136 #define CRYPTOPP_NATIVE_DWORD_AVAILABLE
137 #if defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || defined(__x86_64__) || defined(__mips64) || defined(__sparc64__)
138 #if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !(CRYPTOPP_GCC_VERSION == 40001 && defined(__APPLE__)) && CRYPTOPP_GCC_VERSION >= 30400
139 // GCC 4.0.1 on MacOS X is missing __umodti3 and __udivti3
140 // mode(TI) division broken on amd64 with GCC earlier than GCC 3.4
141 typedef word32 hword;
142 typedef word64 word;
143 typedef __uint128_t dword;
144 typedef __uint128_t word128;
145 #define CRYPTOPP_WORD128_AVAILABLE
146 #else
147 // 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
148 typedef word16 hword;
149 typedef word32 word;
150 typedef word64 dword;
151 #endif
152 #else
153 // being here means the native register size is probably 32 bits or less
154 #define CRYPTOPP_BOOL_SLOW_WORD64 1
155 typedef word16 hword;
156 typedef word32 word;
157 typedef word64 dword;
158 #endif
159 #endif
160 #ifndef CRYPTOPP_BOOL_SLOW_WORD64
161 #define CRYPTOPP_BOOL_SLOW_WORD64 0
162 #endif
164 const unsigned int WORD_SIZE = sizeof(word);
165 const unsigned int WORD_BITS = WORD_SIZE * 8;
167 NAMESPACE_END
169 #ifndef CRYPTOPP_L1_CACHE_LINE_SIZE
170 // This should be a lower bound on the L1 cache line size. It's used for defense against timing attacks.
171 #if defined(_M_X64) || defined(__x86_64__)
172 #define CRYPTOPP_L1_CACHE_LINE_SIZE 64
173 #else
174 // L1 cache line size is 32 on Pentium III and earlier
175 #define CRYPTOPP_L1_CACHE_LINE_SIZE 32
176 #endif
177 #endif
179 #if defined(_MSC_VER)
180 #if _MSC_VER == 1200
181 #include <malloc.h>
182 #endif
183 #if _MSC_VER > 1200 || defined(_mm_free)
184 #define CRYPTOPP_MSVC6PP_OR_LATER // VC 6 processor pack or later
185 #else
186 #define CRYPTOPP_MSVC6_NO_PP // VC 6 without processor pack
187 #endif
188 #endif
190 #ifndef CRYPTOPP_ALIGN_DATA
191 #if defined(CRYPTOPP_MSVC6PP_OR_LATER)
192 #define CRYPTOPP_ALIGN_DATA(x) __declspec(align(x))
193 #elif defined(__GNUC__)
194 #define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x)))
195 #else
196 #define CRYPTOPP_ALIGN_DATA(x)
197 #endif
198 #endif
200 #ifndef CRYPTOPP_SECTION_ALIGN16
201 #if defined(__GNUC__) && !defined(__APPLE__)
202 // the alignment attribute doesn't seem to work without this section attribute when -fdata-sections is turned on
203 #define CRYPTOPP_SECTION_ALIGN16 __attribute__((section ("CryptoPP_Align16")))
204 #else
205 #define CRYPTOPP_SECTION_ALIGN16
206 #endif
207 #endif
209 #if defined(_MSC_VER) || defined(__fastcall)
210 #define CRYPTOPP_FASTCALL __fastcall
211 #else
212 #define CRYPTOPP_FASTCALL
213 #endif
215 // VC60 workaround: it doesn't allow typename in some places
216 #if defined(_MSC_VER) && (_MSC_VER < 1300)
217 #define CPP_TYPENAME
218 #else
219 #define CPP_TYPENAME typename
220 #endif
222 // VC60 workaround: can't cast unsigned __int64 to float or double
223 #if defined(_MSC_VER) && !defined(CRYPTOPP_MSVC6PP_OR_LATER)
224 #define CRYPTOPP_VC6_INT64 (__int64)
225 #else
226 #define CRYPTOPP_VC6_INT64
227 #endif
229 #ifdef _MSC_VER
230 #define CRYPTOPP_NO_VTABLE __declspec(novtable)
231 #else
232 #define CRYPTOPP_NO_VTABLE
233 #endif
235 #ifdef _MSC_VER
236 // 4231: nonstandard extension used : 'extern' before template explicit instantiation
237 // 4250: dominance
238 // 4251: member needs to have dll-interface
239 // 4275: base needs to have dll-interface
240 // 4660: explicitly instantiating a class that's already implicitly instantiated
241 // 4661: no suitable definition provided for explicit template instantiation request
242 // 4786: identifer was truncated in debug information
243 // 4355: 'this' : used in base member initializer list
244 // 4910: '__declspec(dllexport)' and 'extern' are incompatible on an explicit instantiation
245 # pragma warning(disable: 4231 4250 4251 4275 4660 4661 4786 4355 4910)
246 #endif
248 #ifdef __BORLANDC__
249 // 8037: non-const function called for const object. needed to work around BCB2006 bug
250 # pragma warn -8037
251 #endif
253 #if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__MWERKS__) || defined(_STLPORT_VERSION)
254 #define CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION
255 #endif
257 #ifndef CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION
258 #define CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE
259 #endif
261 #ifdef CRYPTOPP_DISABLE_X86ASM // for backwards compatibility: this macro had both meanings
262 #define CRYPTOPP_DISABLE_ASM
263 #define CRYPTOPP_DISABLE_SSE2
264 #endif
266 #if !defined(CRYPTOPP_DISABLE_ASM) && ((defined(_MSC_VER) && defined(_M_IX86)) || (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))))
267 #define CRYPTOPP_X86_ASM_AVAILABLE
269 #if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || CRYPTOPP_GCC_VERSION >= 30300)
270 #define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 1
271 #else
272 #define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 0
273 #endif
275 // 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.
276 // GCC 4.1.2 was released on 2/13/2007, so we'll use that as a proxy for the binutils version.
277 #if !defined(CRYPTOPP_DISABLE_SSSE3) && (_MSC_VER >= 1400 || CRYPTOPP_GCC_VERSION >= 40102)
278 #define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 1
279 #else
280 #define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 0
281 #endif
282 #endif
284 #if !defined(CRYPTOPP_DISABLE_ASM) && defined(_MSC_VER) && defined(_M_X64)
285 #define CRYPTOPP_X64_MASM_AVAILABLE
286 #endif
288 #if !defined(CRYPTOPP_DISABLE_ASM) && defined(__GNUC__) && defined(__x86_64__)
289 #define CRYPTOPP_X64_ASM_AVAILABLE
290 #endif
292 #if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || defined(__SSE2__))
293 #define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 1
294 #else
295 #define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 0
296 #endif
298 #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)
299 #define CRYPTOPP_BOOL_ALIGN16_ENABLED 1
300 #else
301 #define CRYPTOPP_BOOL_ALIGN16_ENABLED 0
302 #endif
304 // how to allocate 16-byte aligned memory (for SSE2)
305 #if defined(CRYPTOPP_MSVC6PP_OR_LATER)
306 #define CRYPTOPP_MM_MALLOC_AVAILABLE
307 #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
308 #define CRYPTOPP_MALLOC_ALIGNMENT_IS_16
309 #elif defined(__linux__) || defined(__sun__) || defined(__CYGWIN__)
310 #define CRYPTOPP_MEMALIGN_AVAILABLE
311 #else
312 #define CRYPTOPP_NO_ALIGNED_ALLOC
313 #endif
315 // how to disable inlining
316 #if defined(_MSC_VER) && _MSC_VER >= 1300
317 # define CRYPTOPP_NOINLINE_DOTDOTDOT
318 # define CRYPTOPP_NOINLINE __declspec(noinline)
319 #elif defined(__GNUC__)
320 # define CRYPTOPP_NOINLINE_DOTDOTDOT
321 # define CRYPTOPP_NOINLINE __attribute__((noinline))
322 #else
323 # define CRYPTOPP_NOINLINE_DOTDOTDOT ...
324 # define CRYPTOPP_NOINLINE
325 #endif
327 // how to declare class constants
328 #if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__INTEL_COMPILER)
329 # define CRYPTOPP_CONSTANT(x) enum {x};
330 #else
331 # define CRYPTOPP_CONSTANT(x) static const int x;
332 #endif
334 #if defined(_M_X64) || defined(__x86_64__)
335 #define CRYPTOPP_BOOL_X64 1
336 #else
337 #define CRYPTOPP_BOOL_X64 0
338 #endif
340 // see http://predef.sourceforge.net/prearch.html
341 #if defined(_M_IX86) || defined(__i386__) || defined(__i386) || defined(_X86_) || defined(__I86__) || defined(__INTEL__)
342 #define CRYPTOPP_BOOL_X86 1
343 #else
344 #define CRYPTOPP_BOOL_X86 0
345 #endif
347 #if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X86 || defined(__powerpc__)
348 #define CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS
349 #endif
351 #define CRYPTOPP_VERSION 560
353 // ***************** determine availability of OS features ********************
355 #ifndef NO_OS_DEPENDENCE
357 #if defined(_WIN32) || defined(__CYGWIN__)
358 #define CRYPTOPP_WIN32_AVAILABLE
359 #endif
361 #if defined(__unix__) || defined(__MACH__) || defined(__NetBSD__) || defined(__sun)
362 #define CRYPTOPP_UNIX_AVAILABLE
363 #endif
365 #if defined(CRYPTOPP_WIN32_AVAILABLE) || defined(CRYPTOPP_UNIX_AVAILABLE)
366 # define HIGHRES_TIMER_AVAILABLE
367 #endif
369 #ifdef CRYPTOPP_UNIX_AVAILABLE
370 # define HAS_BERKELEY_STYLE_SOCKETS
371 #endif
373 #ifdef CRYPTOPP_WIN32_AVAILABLE
374 # define HAS_WINDOWS_STYLE_SOCKETS
375 #endif
377 #if defined(HIGHRES_TIMER_AVAILABLE) && (defined(HAS_BERKELEY_STYLE_SOCKETS) || defined(HAS_WINDOWS_STYLE_SOCKETS))
378 # define SOCKETS_AVAILABLE
379 #endif
381 #if defined(HAS_WINDOWS_STYLE_SOCKETS) && (!defined(HAS_BERKELEY_STYLE_SOCKETS) || defined(PREFER_WINDOWS_STYLE_SOCKETS))
382 # define USE_WINDOWS_STYLE_SOCKETS
383 #else
384 # define USE_BERKELEY_STYLE_SOCKETS
385 #endif
387 #if defined(HIGHRES_TIMER_AVAILABLE) && defined(CRYPTOPP_WIN32_AVAILABLE) && !defined(USE_BERKELEY_STYLE_SOCKETS)
388 # define WINDOWS_PIPES_AVAILABLE
389 #endif
391 #if defined(CRYPTOPP_WIN32_AVAILABLE) && defined(USE_MS_CRYPTOAPI)
392 # define NONBLOCKING_RNG_AVAILABLE
393 # define OS_RNG_AVAILABLE
394 #endif
396 #if defined(CRYPTOPP_UNIX_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING)
397 # define NONBLOCKING_RNG_AVAILABLE
398 # define BLOCKING_RNG_AVAILABLE
399 # define OS_RNG_AVAILABLE
400 # define HAS_PTHREADS
401 # define THREADS_AVAILABLE
402 #endif
404 #ifdef CRYPTOPP_WIN32_AVAILABLE
405 # define HAS_WINTHREADS
406 # define THREADS_AVAILABLE
407 #endif
409 #endif // NO_OS_DEPENDENCE
411 // ***************** DLL related ********************
413 #ifdef CRYPTOPP_WIN32_AVAILABLE
415 #ifdef CRYPTOPP_EXPORTS
416 #define CRYPTOPP_IS_DLL
417 #define CRYPTOPP_DLL __declspec(dllexport)
418 #elif defined(CRYPTOPP_IMPORTS)
419 #define CRYPTOPP_IS_DLL
420 #define CRYPTOPP_DLL __declspec(dllimport)
421 #else
422 #define CRYPTOPP_DLL
423 #endif
425 #define CRYPTOPP_API __cdecl
427 #else // CRYPTOPP_WIN32_AVAILABLE
429 #define CRYPTOPP_DLL
430 #define CRYPTOPP_API
432 #endif // CRYPTOPP_WIN32_AVAILABLE
434 #if defined(__MWERKS__)
435 #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern class CRYPTOPP_DLL
436 #elif defined(__BORLANDC__) || defined(__SUNPRO_CC)
437 #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL
438 #else
439 #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern template class CRYPTOPP_DLL
440 #endif
442 #if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_IMPORTS)
443 #define CRYPTOPP_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL
444 #else
445 #define CRYPTOPP_DLL_TEMPLATE_CLASS CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS
446 #endif
448 #if defined(__MWERKS__)
449 #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern class
450 #elif defined(__BORLANDC__) || defined(__SUNPRO_CC)
451 #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS template class
452 #else
453 #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern template class
454 #endif
456 #if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_EXPORTS)
457 #define CRYPTOPP_STATIC_TEMPLATE_CLASS template class
458 #else
459 #define CRYPTOPP_STATIC_TEMPLATE_CLASS CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS
460 #endif
462 #endif