mp_iseven/mp_isodd should be inline
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
diff --git a/mp_iseven.c b/mp_iseven.c
deleted file mode 100644
index 4ebc9af..0000000
--- a/mp_iseven.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "tommath_private.h"
-#ifdef MP_ISEVEN_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis */
-/* SPDX-License-Identifier: Unlicense */
-
-mp_bool mp_iseven(const mp_int *a)
-{
- return MP_IS_EVEN(a) ? MP_YES : MP_NO;
-}
-#endif
diff --git a/mp_isodd.c b/mp_isodd.c
deleted file mode 100644
index f8a3e0e..0000000
--- a/mp_isodd.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "tommath_private.h"
-#ifdef MP_ISODD_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis */
-/* SPDX-License-Identifier: Unlicense */
-
-mp_bool mp_isodd(const mp_int *a)
-{
- return MP_IS_ODD(a) ? MP_YES : MP_NO;
-}
-#endif
diff --git a/tommath.h b/tommath.h
index f7711e1..5d0d2fe 100644
--- a/tommath.h
+++ b/tommath.h
@@ -209,9 +209,9 @@ mp_err mp_init_size(mp_int *a, int size) MP_WUR;
/* ---> Basic Manipulations <--- */
#define mp_iszero(a) (((a)->used == 0) ? MP_YES : MP_NO)
-mp_bool mp_iseven(const mp_int *a) MP_WUR;
-mp_bool mp_isodd(const mp_int *a) MP_WUR;
#define mp_isneg(a) (((a)->sign != MP_ZPOS) ? MP_YES : MP_NO)
+#define mp_iseven(a) (((a)->used == 0) || (((a)->dp[0] & 1u) == 0u) ? MP_YES : MP_NO)
+#define mp_isodd(a) (((a)->used > 0) && (((a)->dp[0] & 1u) == 1u) ? MP_YES : MP_NO)
/* set to zero */
void mp_zero(mp_int *a);