progs/perftest.c: Use from Glibc syscall numbers.
[catacomb] / math / mpint.c
index d89fb07..971edab 100644 (file)
 
 /* --- 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 <mLib/macros.h>
 #include <mLib/testrig.h>
 
 static int fromuint(dstr *v)