Macro consistancy: Always use function-name as first parameter and type(s) last, as in SET macro's
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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
diff --git a/bn_mp_get_i32.c b/bn_mp_get_i32.c
index 4227a70..616d78d 100644
--- a/bn_mp_get_i32.c
+++ b/bn_mp_get_i32.c
@@ -3,5 +3,5 @@
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
-MP_GET_SIGNED(int32_t, mp_get_i32, mp_get_mag32)
+MP_GET_SIGNED(mp_get_i32, mp_get_mag32, int32_t, uint32_t)
#endif
diff --git a/bn_mp_get_i64.c b/bn_mp_get_i64.c
index cdc2fee..7b1a437 100644
--- a/bn_mp_get_i64.c
+++ b/bn_mp_get_i64.c
@@ -3,5 +3,5 @@
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
-MP_GET_SIGNED(int64_t, mp_get_i64, mp_get_mag64)
+MP_GET_SIGNED(mp_get_i64, mp_get_mag64, int64_t, uint64_t)
#endif
diff --git a/bn_mp_get_l.c b/bn_mp_get_l.c
index f05d105..b025a25 100644
--- a/bn_mp_get_l.c
+++ b/bn_mp_get_l.c
@@ -3,5 +3,5 @@
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
-MP_GET_SIGNED(long, mp_get_l, mp_get_magl)
+MP_GET_SIGNED(mp_get_l, mp_get_magl, long, unsigned long)
#endif
diff --git a/bn_mp_get_ll.c b/bn_mp_get_ll.c
index 92ce058..388a415 100644
--- a/bn_mp_get_ll.c
+++ b/bn_mp_get_ll.c
@@ -3,5 +3,5 @@
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
-MP_GET_SIGNED(long long, mp_get_ll, mp_get_magll)
+MP_GET_SIGNED(mp_get_ll, mp_get_magll, long long, unsigned long long)
#endif
diff --git a/bn_mp_get_mag32.c b/bn_mp_get_mag32.c
index 46e8b29..2e3ca0a 100644
--- a/bn_mp_get_mag32.c
+++ b/bn_mp_get_mag32.c
@@ -3,5 +3,5 @@
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
-MP_GET_MAG(uint32_t, mp_get_mag32)
+MP_GET_MAG(mp_get_mag32, uint32_t)
#endif
diff --git a/bn_mp_get_mag64.c b/bn_mp_get_mag64.c
index 6ff5e5d..daab440 100644
--- a/bn_mp_get_mag64.c
+++ b/bn_mp_get_mag64.c
@@ -3,5 +3,5 @@
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
-MP_GET_MAG(uint64_t, mp_get_mag64)
+MP_GET_MAG(mp_get_mag64, uint64_t)
#endif
diff --git a/bn_mp_get_magl.c b/bn_mp_get_magl.c
index 7e7519d..c808f02 100644
--- a/bn_mp_get_magl.c
+++ b/bn_mp_get_magl.c
@@ -3,5 +3,5 @@
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
-MP_GET_MAG(unsigned long, mp_get_magl)
+MP_GET_MAG(mp_get_magl, unsigned long)
#endif
diff --git a/bn_mp_get_magll.c b/bn_mp_get_magll.c
index 100299d..a26b7ee 100644
--- a/bn_mp_get_magll.c
+++ b/bn_mp_get_magll.c
@@ -3,5 +3,5 @@
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
-MP_GET_MAG(unsigned long long, mp_get_magll)
+MP_GET_MAG(mp_get_magll, unsigned long long)
#endif
diff --git a/tommath_private.h b/tommath_private.h
index ad59c04..3271d7e 100644
--- a/tommath_private.h
+++ b/tommath_private.h
@@ -264,7 +264,7 @@ MP_DEPRECATED(s_mp_reverse) void bn_reverse(unsigned char *s, int len);
return MP_OKAY; \
}
-#define MP_GET_MAG(type, name) \
+#define MP_GET_MAG(name, type) \
type name(const mp_int* a) \
{ \
unsigned i = MP_MIN((unsigned)a->used, (unsigned)((MP_SIZEOF_BITS(type) + MP_DIGIT_BIT - 1) / MP_DIGIT_BIT)); \
@@ -277,10 +277,10 @@ MP_DEPRECATED(s_mp_reverse) void bn_reverse(unsigned char *s, int len);
return res; \
}
-#define MP_GET_SIGNED(type, name, mag) \
+#define MP_GET_SIGNED(name, mag, type, utype) \
type name(const mp_int* a) \
{ \
- uint64_t res = mag(a); \
+ utype res = mag(a); \
return (a->sign == MP_NEG) ? (type)-res : (type)res; \
}