X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/0f00dc4c8eb47e67bc0f148c2dd109f73a451e0a..HEAD:/math/mpint.c diff --git a/math/mpint.c b/math/mpint.c index d89fb078..971edabb 100644 --- a/math/mpint.c +++ b/math/mpint.c @@ -33,21 +33,12 @@ /* --- Conversion from C integers --- */ -#define FROM(name, type) \ +#define FROM(name, type, max) \ mp *mp_from##name(mp *d, type i) { \ MP_FROMINT(d, type, i); \ return (d); \ } - -FROM(short, short) -FROM(ushort, unsigned short) -FROM(int, int) -FROM(uint, unsigned) -FROM(uint32, uint32) -FROM(long, long) -FROM(ulong, unsigned long) - -#undef FROM +MPINT_CONVERSIONS(FROM) /* --- Conversion to C integers --- */ @@ -58,14 +49,7 @@ FROM(ulong, unsigned long) MP_TOINT(m, type, max, i); \ return (i); \ } - -TO(short, short, SHRT_MAX) -TO(ushort, unsigned short, USHRT_MAX) -TO(int, int, INT_MAX) -TO(uint, unsigned, UINT_MAX) -TO(uint32, uint32, 0xffffffff) -TO(long, long, LONG_MAX) -TO(ulong, unsigned long, ULONG_MAX) +MPINT_CONVERSIONS(TO) #undef TO @@ -73,6 +57,7 @@ TO(ulong, unsigned long, ULONG_MAX) #ifdef TEST_RIG +#include #include static int fromuint(dstr *v)