chiark / gitweb /
rand/rand-x86ish.S: Hoist argument register allocation outside.
[catacomb] / math / mpint.h
index 637ec10e5f6649a99f24520511ea6e104abfccc7..a5ab3dfe866788e5babc7a3d48772ff96b4f86ce 100644 (file)
        MP_ENSURE(_d, _sz);                                             \
       }                                                                        \
       _d->v[_o++] = MPW(_i);                                           \
-      if (_i <= MPW_MAX)                                               \
+      if (MUFFLE_WARNINGS_EXPR(                                                \
+           CLANG_WARNING("-Wtautological-constant-out-of-range-compare"), \
+           _i <= MPW_MAX))                                             \
        break;                                                          \
       else                                                             \
-       MUFFLE_WARNINGS_STMT(GCC_WARNING("-Wdiv-by-zero"), {            \
+       MUFFLE_WARNINGS_STMT(GCC_WARNING("-Wdiv-by-zero")               \
+                            CLANG_WARNING("-Wdivision-by-zero"), {     \
          _i /= (type)MPW_MAX + 1;                                      \
        });                                                             \
     }                                                                  \
        MP_ENSURE(_d, _sz);                                             \
       }                                                                        \
       _d->v[_o++] = MPW(-_i);                                          \
-      if (_i >= -MPW_MAX)                                              \
+      if (MUFFLE_WARNINGS_EXPR(                                                \
+           CLANG_WARNING("-Wtautological-constant-out-of-range-compare"), \
+           _i >= -MPW_MAX))                                            \
        break;                                                          \
       else                                                             \
-       MUFFLE_WARNINGS_STMT(GCC_WARNING("-Wdiv-by-zero"), {            \
+       MUFFLE_WARNINGS_STMT(GCC_WARNING("-Wdiv-by-zero")               \
+                            CLANG_WARNING("-Wdivision-by-zero"), {     \
          _i /= (type)MPW_MAX + 1;                                      \
        });                                                             \
     }                                                                  \
   /* --- Do all the arithmetic in negative numbers --- */              \
                                                                        \
   while (_v < _vl && _max > 0) {                                       \
-    _i -= *_v << _s;                                                   \
+    _i -= (type)*_v << _s;                                             \
     _s += MPW_BITS;                                                    \
     _v++;                                                              \
     _max /= (mpd)MPW_MAX + 1;                                          \
 
 /* --- 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@ --- *
  *