From: Mark Wooding Date: Wed, 18 Mar 2015 19:03:16 +0000 (+0000) Subject: math/mpint.h: Add new conversions. X-Git-Tag: 2.2.0~7^2~4 X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/commitdiff_plain/cc08c5707b2b54dbd6b90799cf6df57ab7cacfc5 math/mpint.h: Add new conversions. Cover the remaining types, `long long', `intmax_t', and `size_t'. Conversions for the non-C89 types are only defined if the types are actually detected. --- diff --git a/math/mpint.h b/math/mpint.h index 637ec10e..1b0a7623 100644 --- a/math/mpint.h +++ b/math/mpint.h @@ -147,6 +147,31 @@ /* --- Build up the list of conversions to be supplied --- */ +#ifdef ULLONG_MAX +# ifndef LLONG_MAX +# define LLONG_MAX LONG_LONG_MAX +# endif +# define MPINT_CONV_LLONG(_) \ + _(llong, long long, LLONG_MAX) \ + _(ullong, unsigned long long, ULLONG_MAX) +#else +# define MPINT_CONV_LLONG(_) +#endif + +#ifdef INTMAX_MAX +# define MPINT_CONV_INTMAX(_) \ + _(intmax, intmax_t, INTMAX_MAX) \ + _(uintmax, uintmax_t, UINTMAX_MAX) +#else +# define MPINT_CONV_INTMAX(_) +#endif + +#ifdef HAVE_UINT64 +# define MPINT_CONV_U64(_) _(uint64, uint64, MASK64) +#else +# define MPINT_CONV_U64(_) +#endif + #define MPINT_CONVERSIONS(_) \ _(short, short, SHRT_MAX) \ _(ushort, unsigned short, USHRT_MAX) \ @@ -154,7 +179,14 @@ _(uint, unsigned, UINT_MAX) \ _(long, long, LONG_MAX) \ _(ulong, unsigned long, ULONG_MAX) \ - _(uint32, uint32, MASK32) + MPINT_CONV_LLONG(_) \ + _(uint8, uint8, MASK8) \ + _(uint16, uint16, MASK16) \ + _(uint24, uint24, MASK24) \ + _(uint32, uint32, MASK32) \ + MPINT_CONV_U64(_) \ + MPINT_CONV_INTMAX(_) \ + _(sizet, size_t, (size_t)-1) /* --- @mp_fromINT@ --- * *