mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-25 01:02:24 +00:00
Add some appropriate bignum typedefs for generic 64-bit systems,
setting BignumInt to 32 bits. gcc defines _LP64 on x86-64 and presumably on other 64-bit architectures, so I've conditioned my defines on that in the hope that they won't need redoing for the next few such architectures. I've also added a set for _LLP64, but it's untested as yet. [originally from svn r9092]
This commit is contained in:
parent
7c61c07eb8
commit
8b4c50be45
27
sshbn.c
27
sshbn.c
@ -51,7 +51,34 @@ typedef unsigned __int64 BignumDblInt;
|
||||
__asm mov r, edx \
|
||||
__asm mov q, eax \
|
||||
} while(0)
|
||||
#elif defined _LP64
|
||||
/* 64-bit architectures can do 32x32->64 chunks at a time */
|
||||
typedef unsigned int BignumInt;
|
||||
typedef unsigned long BignumDblInt;
|
||||
#define BIGNUM_INT_MASK 0xFFFFFFFFU
|
||||
#define BIGNUM_TOP_BIT 0x80000000U
|
||||
#define BIGNUM_INT_BITS 32
|
||||
#define MUL_WORD(w1, w2) ((BignumDblInt)w1 * w2)
|
||||
#define DIVMOD_WORD(q, r, hi, lo, w) do { \
|
||||
BignumDblInt n = (((BignumDblInt)hi) << BIGNUM_INT_BITS) | lo; \
|
||||
q = n / w; \
|
||||
r = n % w; \
|
||||
} while (0)
|
||||
#elif defined _LLP64
|
||||
/* 64-bit architectures in which unsigned long is 32 bits, not 64 */
|
||||
typedef unsigned long BignumInt;
|
||||
typedef unsigned long long BignumDblInt;
|
||||
#define BIGNUM_INT_MASK 0xFFFFFFFFUL
|
||||
#define BIGNUM_TOP_BIT 0x80000000UL
|
||||
#define BIGNUM_INT_BITS 32
|
||||
#define MUL_WORD(w1, w2) ((BignumDblInt)w1 * w2)
|
||||
#define DIVMOD_WORD(q, r, hi, lo, w) do { \
|
||||
BignumDblInt n = (((BignumDblInt)hi) << BIGNUM_INT_BITS) | lo; \
|
||||
q = n / w; \
|
||||
r = n % w; \
|
||||
} while (0)
|
||||
#else
|
||||
/* Fallback for all other cases */
|
||||
typedef unsigned short BignumInt;
|
||||
typedef unsigned long BignumDblInt;
|
||||
#define BIGNUM_INT_MASK 0xFFFFU
|
||||
|
Loading…
Reference in New Issue
Block a user