mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
Allow command-line override of the BignumInt type.
This makes it easy to re-test the mpint functions using different word sizes and smoke out any more confusions between integer types in mpint.c, by recompiling with -DBIGNUM_OVERRIDE=4 or =5 or =6 (for 16-, 32- or 64-bit respectively). BIGNUM_OVERRIDE only lets you force the size downwards, not upwards: of course the default behaviour is to use the largest BignumInt the ifdefs can find a way to, and they can't magic up a bigger one just because you tell them you'd like one.
This commit is contained in:
parent
48f4b0a36c
commit
55ea49de1e
25
mpint_i.h
25
mpint_i.h
@ -57,7 +57,11 @@
|
||||
* too.
|
||||
*/
|
||||
|
||||
#if defined __SIZEOF_INT128__
|
||||
/* You can lower the BignumInt size by defining BIGNUM_OVERRIDE on the
|
||||
* command line to be your chosen max value of BIGNUM_INT_BITS_BITS */
|
||||
#define BB_OK(b) (!defined BIGNUM_OVERRIDE || BIGNUM_OVERRIDE >= b)
|
||||
|
||||
#if defined __SIZEOF_INT128__ && BB_OK(6)
|
||||
|
||||
/*
|
||||
* 64-bit BignumInt using gcc/clang style 128-bit BignumDblInt.
|
||||
@ -72,7 +76,7 @@
|
||||
#define BIGNUM_INT_BITS_BITS 6
|
||||
#define DEFINE_BIGNUMDBLINT typedef __uint128_t BignumDblInt
|
||||
|
||||
#elif defined _MSC_VER && defined _M_AMD64
|
||||
#elif defined _MSC_VER && defined _M_AMD64 && BB_OK(6)
|
||||
|
||||
/*
|
||||
* 64-bit BignumInt, using Visual Studio x86-64 compiler intrinsics.
|
||||
@ -119,7 +123,7 @@
|
||||
(rh) = MULADD_hi; \
|
||||
} while (0)
|
||||
|
||||
#elif defined __GNUC__ || defined _LLP64 || __STDC__ >= 199901L
|
||||
#elif (defined __GNUC__ || defined _LLP64 || __STDC__ >= 199901L) && BB_OK(5)
|
||||
|
||||
/* 32-bit BignumInt, using C99 unsigned long long as BignumDblInt */
|
||||
|
||||
@ -127,7 +131,7 @@
|
||||
#define BIGNUM_INT_BITS_BITS 5
|
||||
#define DEFINE_BIGNUMDBLINT typedef unsigned long long BignumDblInt
|
||||
|
||||
#elif defined _MSC_VER && defined _M_IX86
|
||||
#elif defined _MSC_VER && defined _M_IX86 && BB_OK(5)
|
||||
|
||||
/* 32-bit BignumInt, using Visual Studio __int64 as BignumDblInt */
|
||||
|
||||
@ -135,7 +139,7 @@
|
||||
#define BIGNUM_INT_BITS_BITS 5
|
||||
#define DEFINE_BIGNUMDBLINT typedef unsigned __int64 BignumDblInt
|
||||
|
||||
#elif defined _LP64
|
||||
#elif defined _LP64 && BB_OK(5)
|
||||
|
||||
/*
|
||||
* 32-bit BignumInt, using unsigned long itself as BignumDblInt.
|
||||
@ -147,7 +151,7 @@
|
||||
#define BIGNUM_INT_BITS_BITS 5
|
||||
#define DEFINE_BIGNUMDBLINT typedef unsigned long BignumDblInt
|
||||
|
||||
#else
|
||||
#elif BB_OK(4)
|
||||
|
||||
/*
|
||||
* 16-bit BignumInt, using unsigned long as BignumDblInt.
|
||||
@ -163,8 +167,17 @@
|
||||
#define BIGNUM_INT_BITS_BITS 4
|
||||
#define DEFINE_BIGNUMDBLINT typedef unsigned long BignumDblInt
|
||||
|
||||
#else
|
||||
|
||||
/* Should only get here if BB_OK(4) evaluated false, i.e. the
|
||||
* command line defined BIGNUM_OVERRIDE to an absurdly small
|
||||
* value. */
|
||||
#error Must define BIGNUM_OVERRIDE to at least 4
|
||||
|
||||
#endif
|
||||
|
||||
#undef BB_OK
|
||||
|
||||
/*
|
||||
* Common code across all branches of that ifdef: define all the
|
||||
* easy constant macros in terms of BIGNUM_INT_BITS_BITS.
|
||||
|
Loading…
Reference in New Issue
Block a user