math/mpint.h: Add new conversions.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 18 Mar 2015 19:03:16 +0000 (19:03 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 22 Mar 2015 01:02:46 +0000 (01:02 +0000)
Cover the remaining <mLib/bits.h> types, `long long', `intmax_t', and
`size_t'.

Conversions for the non-C89 types are only defined if the types are
actually detected.

math/mpint.h

index 637ec10..1b0a762 100644 (file)
 
 /* --- 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)                                 \
   _(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@ --- *
  *