summaryrefslogtreecommitdiffstats
path: root/mpi/mpi.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-04-22 19:55:19 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-04-22 19:55:19 -0700
commit150e147b77199684b32c327e4d3e2715fd2d7a0f (patch)
tree171ebf24ae26a036d04f04b0a6a0bfd2d56d9c87 /mpi/mpi.h
parent5f4b704f40f30d19468078ace5f7624c1225faa6 (diff)
downloadtxr-150e147b77199684b32c327e4d3e2715fd2d7a0f.tar.gz
txr-150e147b77199684b32c327e4d3e2715fd2d7a0f.tar.bz2
txr-150e147b77199684b32c327e4d3e2715fd2d7a0f.zip
add-bitops patch
Adding bit operations to MPI. * mpi/mpi.c (MAX, MIN): New macros. (mp_2comp, mp_and, mp_or, mp_xor, mp_comp, mp_trunc, mp_shift, mp_bit): New functions. * mpi/mpi.h (mp_2comp, mp_and, mp_or, mp_xor, mp_comp, mp_trunc, mp_shift, mp_bit): Declared.
Diffstat (limited to 'mpi/mpi.h')
-rw-r--r--mpi/mpi.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/mpi/mpi.h b/mpi/mpi.h
index c6136c15..98280247 100644
--- a/mpi/mpi.h
+++ b/mpi/mpi.h
@@ -54,6 +54,7 @@
/* 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)
@@ -187,6 +188,18 @@ mp_err mp_invmod(mp_int *a, mp_int *m, mp_int *c);
#endif /* end MP_NUMTH */
/*------------------------------------------------------------------------*/
+/* Bit ops */
+mp_err mp_2comp(mp_int *a, mp_int *b, mp_size dig); /* peculiar semantics */
+mp_err mp_and(mp_int *a, mp_int *b, mp_int *c);
+mp_err mp_or(mp_int *a, mp_int *b, mp_int *c);
+mp_err mp_xor(mp_int *a, mp_int *b, mp_int *c);
+mp_err mp_comp(mp_int *a, mp_int *b);
+mp_err mp_trunc_comp(mp_int *a, mp_int *b, mp_digit bits);
+mp_err mp_trunc(mp_int *a, mp_int *b, mp_digit bits);
+mp_err mp_shift(mp_int *a, mp_int *b, int bits); /* + left, - right */
+mp_err mp_bit(mp_int *a, mp_digit bit);
+
+/*------------------------------------------------------------------------*/
/* Conversions */
mp_err mp_to_double(mp_int *mp, double *d);