Commit 91b113cb95356208b6ddc330959f1086805303df

nijtmans 2019-06-12T13:44:59

Macro consistancy: Always use function-name as first parameter and type(s) last, as in SET macro's

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;  \
     }