summaryrefslogtreecommitdiffstats
path: root/mpi
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-01-22 19:05:42 -0800
committerKaz Kylheku <kaz@kylheku.com>2019-01-22 19:05:42 -0800
commitceac286861928128d066b31c43e32a6034df0afb (patch)
tree9dbbc6c4ede2ba39f0d636f4f3a1c67a20f9aec6 /mpi
parent812e34fccb1fe84d9127e2b294e6490e0bde4b00 (diff)
downloadtxr-ceac286861928128d066b31c43e32a6034df0afb.tar.gz
txr-ceac286861928128d066b31c43e32a6034df0afb.tar.bz2
txr-ceac286861928128d066b31c43e32a6034df0afb.zip
mpi: put access macros into mp_ namespace
* mpi/mpi.h (mp_sign, mp_isneg, mp_used, mp_alloc, mp_digits, mp_digit): New macros, based on renaming SIGN, ISNEG, USED, ALLOC, DIGITS and DIGIT. (mp_set_prec): Use mp_digits instead of DIGITS. * mpi/mpi.c (SIGN, ISNEG, USED, ALLOC, DIGITS, DIGIT): Macros defined here now, as local aliases for their namespaced counterparts. * arith.c (signum, floordiv): Replace ISNEG with mp_isneg. * rand.c (random): Replace ISNEG with mp_isneg. * sysif.c (off_t_num): Replace USED, DIGITS and ISNEG with mp_used, mp_digits and mp_isneg.
Diffstat (limited to 'mpi')
-rw-r--r--mpi/mpi.c8
-rw-r--r--mpi/mpi.h14
2 files changed, 15 insertions, 7 deletions
diff --git a/mpi/mpi.c b/mpi/mpi.c
index ef91437b..ff11f2e2 100644
--- a/mpi/mpi.c
+++ b/mpi/mpi.c
@@ -74,6 +74,14 @@ static mp_size s_mp_defprec = MP_DEFPREC;
#define ARGCHK(X,Y)
#endif
+/* Nicknames for access macros */
+#define SIGN(MP) mp_sign(MP)
+#define ISNEG(MP) mp_isneg(MP)
+#define USED(MP) mp_used(MP)
+#define ALLOC(MP) mp_alloc(MP)
+#define DIGITS(MP) mp_digits(MP)
+#define DIGIT(MP,N) mp_digit(MP,N)
+
/* This defines the maximum I/O base (minimum is 2) */
#define MAX_RADIX 64
diff --git a/mpi/mpi.h b/mpi/mpi.h
index 0fd9b740..28fadb31 100644
--- a/mpi/mpi.h
+++ b/mpi/mpi.h
@@ -49,12 +49,12 @@ typedef struct {
} mp_int;
/* Macros for accessing the mp_int internals */
-#define SIGN(MP) ((MP)->sign)
-#define ISNEG(MP) ((MP)->sign == MP_NEG)
-#define USED(MP) ((MP)->used)
-#define ALLOC(MP) ((MP)->alloc)
-#define DIGITS(MP) ((MP)->dp)
-#define DIGIT(MP,N) (MP)->dp[(N)]
+#define mp_sign(MP) ((MP)->sign)
+#define mp_isneg(MP) ((MP)->sign == MP_NEG)
+#define mp_used(MP) ((MP)->used)
+#define mp_alloc(MP) ((MP)->alloc)
+#define mp_digits(MP) ((MP)->dp)
+#define mp_digit(MP,N) (MP)->dp[(N)]
#ifdef __GNUC__
#define mp_nign __attribute__((warn_unused_result))
@@ -68,7 +68,7 @@ void mp_set_prec(mp_size prec);
mp_err mp_init(mp_int *mp);
INLINE mp_err mp_init_minimal(mp_int *mp)
{
- DIGITS(mp) = 0;
+ mp_digits(mp) = 0;
return MP_OKAY;
}
mp_err mp_init_array(mp_int mp[], int count);