diff options
author | Geoff Thorpe <geoff@openssl.org> | 2003-11-04 00:29:09 +0000 |
---|---|---|
committer | Geoff Thorpe <geoff@openssl.org> | 2003-11-04 00:29:09 +0000 |
commit | c465e7941ec785f2ce53638b351a21d6a49fe1a0 (patch) | |
tree | b55fe5ccc4a521d1d117239f944b1325840e3fb8 /crypto/bn/bn.h | |
parent | 933398f1102ba99d64f901987c5e8fe340a2c331 (diff) |
This is the least unacceptable way I've found for declaring the bignum data
and structures as constant without having to cast away const at any point.
There is still plenty of other code that makes gcc's "-Wcast-qual" unhappy,
but crypto/bn/ is now ok. Purists are welcome to suggest alternatives.
Diffstat (limited to 'crypto/bn/bn.h')
-rw-r--r-- | crypto/bn/bn.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/crypto/bn/bn.h b/crypto/bn/bn.h index 686b3b3079..44ba175247 100644 --- a/crypto/bn/bn.h +++ b/crypto/bn/bn.h @@ -252,6 +252,27 @@ typedef struct bignum_st int flags; } BIGNUM; +/* Declaring static BIGNUMs as constant is tricky in C; the 'd' data can't be + * pre-declared const without having to cast away the const when declaring the + * BIGNUM. We use this alternative type for declaring const BIGNUMs. See + * bn_nist.c for examples. */ +typedef struct bignum_c_st + { + const BN_ULONG *d; + int top; + int dmax; + int neg; + int flags; + } BIGNUM_C; +#ifdef BN_DEBUG +/* Use a function to do this so that we can type-check the pointer we're + * casting */ +const BIGNUM *BIGNUM_CONST(const BIGNUM_C *bn); +#else +/* Use a macro instead */ +#define BIGNUM_CONST(bn) ((const BIGNUM *)bn) +#endif + /* Used for temp variables (declaration hidden in bn_lcl.h) */ typedef struct bignum_ctx BN_CTX; |