comparison libtommath/tommath.h @ 1470:8bba51a55704

Update to libtommath v1.0.1
author Matt Johnston <matt@ucc.asn.au>
date Thu, 08 Feb 2018 23:11:40 +0800
parents 60fc6476e044
children f52919ffd3b1
comparison
equal deleted inserted replaced
1469:51043e868f55 1470:8bba51a55704
25 #ifdef __cplusplus 25 #ifdef __cplusplus
26 extern "C" { 26 extern "C" {
27 #endif 27 #endif
28 28
29 /* detect 64-bit mode if possible */ 29 /* detect 64-bit mode if possible */
30 #if defined(__x86_64__) 30 #if defined(__x86_64__) || defined(_M_X64) || defined(_M_AMD64) || \
31 defined(__powerpc64__) || defined(__ppc64__) || defined(__PPC64__) || \
32 defined(__s390x__) || defined(__arch64__) || defined(__aarch64__) || \
33 defined(__sparcv9) || defined(__sparc_v9__) || defined(__sparc64__) || \
34 defined(__ia64) || defined(__ia64__) || defined(__itanium__) || defined(_M_IA64) || \
35 defined(__LP64__) || defined(_LP64) || defined(__64BIT__)
31 #if !(defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT)) 36 #if !(defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT))
32 #define MP_64BIT 37 #define MP_64BIT
33 #endif 38 #endif
34 #endif 39 #endif
35 40
92 typedef uint_least32_t mp_min_u32; 97 typedef uint_least32_t mp_min_u32;
93 #else 98 #else
94 typedef mp_digit mp_min_u32; 99 typedef mp_digit mp_min_u32;
95 #endif 100 #endif
96 101
97 /* platforms that can use a better rand function */ 102 /* use arc4random on platforms that support it */
98 #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) 103 #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
99 #define MP_USE_ALT_RAND 1
100 #endif
101
102 /* use arc4random on platforms that support it */
103 #ifdef MP_USE_ALT_RAND
104 #define MP_GEN_RANDOM() arc4random() 104 #define MP_GEN_RANDOM() arc4random()
105 #else 105 #define MP_GEN_RANDOM_MAX 0xffffffff
106 #endif
107
108 /* use rand() as fall-back if there's no better rand function */
109 #ifndef MP_GEN_RANDOM
106 #define MP_GEN_RANDOM() rand() 110 #define MP_GEN_RANDOM() rand()
111 #define MP_GEN_RANDOM_MAX RAND_MAX
107 #endif 112 #endif
108 113
109 #define MP_DIGIT_BIT DIGIT_BIT 114 #define MP_DIGIT_BIT DIGIT_BIT
110 #define MP_MASK ((((mp_digit)1)<<((mp_digit)DIGIT_BIT))-((mp_digit)1)) 115 #define MP_MASK ((((mp_digit)1)<<((mp_digit)DIGIT_BIT))-((mp_digit)1))
111 #define MP_DIGIT_MAX MP_MASK 116 #define MP_DIGIT_MAX MP_MASK
558 #endif 563 #endif
559 564
560 #endif 565 #endif
561 566
562 567
563 /* $Source: /cvs/libtom/libtommath/tommath.h,v $ */ 568 /* ref: $Format:%D$ */
564 /* $Revision: 1.8 $ */ 569 /* git commit: $Format:%H$ */
565 /* $Date: 2006/03/31 14:18:44 $ */ 570 /* commit time: $Format:%ai$ */