diff options
author | Richard Levitte <levitte@openssl.org> | 2021-06-18 10:32:32 +0200 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2021-06-22 19:49:52 +1000 |
commit | 08ee6addf7343e7523db47dcc7e84e1670d52e15 (patch) | |
tree | a1aa4a49855e41815f928fbd31d7be7d183bc6c0 /include | |
parent | b1fa45b01ba55a95bea1a4f05444f40be1b126f5 (diff) |
Fix definition of ossl_intmax_t and ossl_uintmax_t
These definitions were located away from our definitions of other
sized int and uint types. Also, the fallback typedef wasn't quite
correct, and this changes it to be aliases for int64_t and uint64_t,
since those are the largest integers we commonly handle.
We also make sure to define corresponding numbers: OSSL_INTMAX_MIN,
OSSL_INTMAX_MAX and OSSL_UINTMAX_MAX
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15825)
Diffstat (limited to 'include')
-rw-r--r-- | include/internal/numbers.h | 6 | ||||
-rw-r--r-- | include/openssl/e_os2.h | 9 | ||||
-rw-r--r-- | include/openssl/types.h | 15 |
3 files changed, 15 insertions, 15 deletions
diff --git a/include/internal/numbers.h b/include/internal/numbers.h index ac801364d9..4f4d3306d5 100644 --- a/include/internal/numbers.h +++ b/include/internal/numbers.h @@ -75,5 +75,11 @@ typedef __uint128_t uint128_t; # define SIZE_MAX __MAXUINT__(size_t) # endif +# ifndef OSSL_INTMAX_MAX +# define OSSL_INTMAX_MIN __MININT__(ossl_intmax_t) +# define OSSL_INTMAX_MAX __MAXINT__(ossl_intmax_t) +# define OSSL_UINTMAX_MAX __MAXUINT__(ossl_uintmax_t) +# endif + #endif diff --git a/include/openssl/e_os2.h b/include/openssl/e_os2.h index 49e6dad73c..6728909271 100644 --- a/include/openssl/e_os2.h +++ b/include/openssl/e_os2.h @@ -252,6 +252,15 @@ typedef unsigned __int64 uint64_t; # include <stdint.h> # undef OPENSSL_NO_STDINT_H # endif +# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && \ + defined(INTMAX_MAX) && defined(UINTMAX_MAX) +typedef intmax_t ossl_intmax_t; +typedef uintmax_t ossl_uintmax_t; +# else +/* Fall back to the largest we know we require and can handle */ +typedef int64_t ossl_intmax_t; +typedef uint64_t ossl_uintmax_t; +# endif /* ossl_inline: portable inline definition usable in public headers */ # if !defined(inline) && !defined(__cplusplus) diff --git a/include/openssl/types.h b/include/openssl/types.h index bf5846db05..de9f166524 100644 --- a/include/openssl/types.h +++ b/include/openssl/types.h @@ -229,21 +229,6 @@ typedef struct ossl_decoder_ctx_st OSSL_DECODER_CTX; typedef struct ossl_self_test_st OSSL_SELF_TEST; -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && \ - defined(INTMAX_MAX) && defined(UINTMAX_MAX) -typedef intmax_t ossl_intmax_t; -typedef uintmax_t ossl_uintmax_t; -#else -/* - * Not long long, because the C-library can only be expected to provide - * strtoll(), strtoull() at the same time as intmax_t and strtoimax(), - * strtoumax(). Since we use these for parsing arguments, we need the - * conversion functions, not just the sizes. - */ -typedef long ossl_intmax_t; -typedef unsigned long ossl_uintmax_t; -#endif - #ifdef __cplusplus } #endif |