replace PRIx64 by MP_PRIx64 for c89 mode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
diff --git a/makefile b/makefile
index c06849a..4694189 100644
--- a/makefile
+++ b/makefile
@@ -161,20 +161,10 @@ c89:
-e 's/bool/mp_bool/g' \
-e 's/true/MP_YES/g' \
-e 's/false/MP_NO/g' \
+ -e 's/\(PRI[iux]64\)/MP_\1/g' \
-e 's/uint\([0-9][0-9]*\)_t/mp_u\1/g' \
-e 's/int\([0-9][0-9]*\)_t/mp_i\1/g' \
- *.c *.h demo/*.c demo/*.h etc/*.c
- @echo "/* please adapt this header to your needs */" > tommath_c89.h
- @echo "typedef enum { MP_NO, MP_YES } mp_bool;" >> tommath_c89.h
- @echo "typedef __INT8_TYPE__ mp_i8;" >> tommath_c89.h
- @echo "typedef __INT16_TYPE__ mp_i16;" >> tommath_c89.h
- @echo "typedef __INT32_TYPE__ mp_i32;" >> tommath_c89.h
- @echo "typedef __INT64_TYPE__ mp_i64;" >> tommath_c89.h
- @echo "typedef __UINT8_TYPE__ mp_u8;" >> tommath_c89.h
- @echo "typedef __UINT16_TYPE__ mp_u16;" >> tommath_c89.h
- @echo "typedef __UINT32_TYPE__ mp_u32;" >> tommath_c89.h
- @echo "typedef __UINT64_TYPE__ mp_u64;" >> tommath_c89.h
-
+ *.c tommath.h tommath_private.h demo/*.c demo/*.h etc/*.c
c99:
@echo "Applying substitutions for c99 compatibility..."
@@ -185,11 +175,10 @@ c99:
-e 's/MP_YES/true/g' \
-e 's/MP_NO/false/g' \
-e 's/false_/MP_NO_/g' \
+ -e 's/MP_\(PRI[iux]64\)/\1/g' \
-e 's/mp_u\([0-9][0-9]*\)/uint\1_t/g' \
-e 's/mp_i\([0-9][0-9]*\)/int\1_t/g' \
- *.c *.h demo/*.c demo/*.h etc/*.c
- @rm -f tommath_c89.h
-
+ *.c tommath.h tommath_private.h demo/*.c demo/*.h etc/*.c
astyle:
@echo " * run astyle on all sources"
diff --git a/tommath_c89.h b/tommath_c89.h
new file mode 100644
index 0000000..e2beab8
--- /dev/null
+++ b/tommath_c89.h
@@ -0,0 +1,18 @@
+/* please adapt this header to your needs */
+typedef enum { MP_NO, MP_YES } mp_bool;
+typedef __INT8_TYPE__ mp_i8;
+typedef __INT16_TYPE__ mp_i16;
+typedef __INT32_TYPE__ mp_i32;
+typedef __INT64_TYPE__ mp_i64;
+typedef __UINT8_TYPE__ mp_u8;
+typedef __UINT16_TYPE__ mp_u16;
+typedef __UINT32_TYPE__ mp_u32;
+typedef __UINT64_TYPE__ mp_u64;
+# if __WORDSIZE == 64
+# define MP_PRI64_PREFIX "l"
+# else
+# define MP_PRI64_PREFIX "ll"
+# endif
+#define MP_PRIi64 MP_PRI64_PREFIX "i"
+#define MP_PRIu64 MP_PRI64_PREFIX "u"
+#define MP_PRIx64 MP_PRI64_PREFIX "x"