diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2011-12-09 22:25:51 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2011-12-09 22:25:51 -0800 |
commit | 236a20e92316535bc75dde63d51431875e253bfb (patch) | |
tree | 6ec4fb84a27cb311027495db9d3c34b791fe207e /mpi-patches/config-types | |
parent | b1088a2502cba1a61b862f708489c8d4baa722fe (diff) | |
download | txr-236a20e92316535bc75dde63d51431875e253bfb.tar.gz txr-236a20e92316535bc75dde63d51431875e253bfb.tar.bz2 txr-236a20e92316535bc75dde63d51431875e253bfb.zip |
Bignum support, here we go!
Bignums, based on Michael Fromberger's MPI library, are integrated
into the input syntax, stream output, equality testing, the garbage
collector, and hashing.
The plus operation handles transitions between fixnums and bignums.
Other operations are still fixnum only.
* Makefile (CFLAGS): Add mpi directory to include file search.
(OBJS): Include new arith.o module and all of MPI_OBJS.
(MPI_OBJS, MPI_OBJS_BASE): New variables.
* configure (mpi_version, have_quilt, have_patch): New variables.
Script detects whether patch and quilt are available. Unpacks
mpi library, applies patches. Detects 128 bit integer type.
Records more information in config.h about the sizes of types.
* dep.mk: Updated.
* depend.txr: Make work with paths that have directory components.
* eval.c (eval_init): Rename of nump to fixnump.
* gc.c (finalize, mark_obj): Handle BGNUM case.
* hash.c: (hash_c_str): Changed to return unsigned long
instead of long.
(equal_hash): Handle BGNUM case.
(eql_hash): Handle bignums with equal-hash, but other
objects as eq.
* lib.c (num_s): Variable renamed to fixnum_s.
(bignum_s): New symbol variable.
(code2type): Follow rename of num_s. Handle BGNUM case.
(typeof): Follow rename of num_s.
(eql): Handle bignums using equal, and other types using eq.
(equal): Handle BGNUM case.
(chk_calloc): New function.
(c_num): Wording change in error message: is not a fixnum.
(nump): Renamed to fixnump.
(bignump): New function.
(plus): Function removed, reimplemented in arith.c.
(int_str): Handle integers which are too large for wcstol
using bignum conversion. Base 0 is no longer passed to
wcstol but converted to 10 because the special semantics
for 0 would be inconsistent for bignums.
(obj_init): Follow rename of num_s. Initialize bignum_s.
Diffstat (limited to 'mpi-patches/config-types')
-rw-r--r-- | mpi-patches/config-types | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/mpi-patches/config-types b/mpi-patches/config-types new file mode 100644 index 00000000..78b672b8 --- /dev/null +++ b/mpi-patches/config-types @@ -0,0 +1,120 @@ +Index: mpi-1.8.6/mpi-types.h +=================================================================== +--- mpi-1.8.6.orig/mpi-types.h 2011-12-09 09:00:59.000000000 -0800 ++++ mpi-1.8.6/mpi-types.h 2011-12-09 14:09:59.000000000 -0800 +@@ -1,17 +1,54 @@ +-/* Type definitions generated by 'types.pl' */ ++/* ++ * Universal. We can further tweak these by making them ++ * bitfields inside the mp_int struct. ++ */ ++typedef int mp_sign; ++typedef int mp_size; + +-typedef char mp_sign; +-typedef unsigned short mp_digit; /* 2 byte type */ +-typedef unsigned int mp_word; /* 4 byte type */ +-typedef unsigned int mp_size; +-typedef int mp_err; ++/* ++ * Universal. Does not need platform configuration. ++ */ ++typedef int mp_err; + +-#define MP_DIGIT_BIT (CHAR_BIT*sizeof(mp_digit)) +-#define MP_DIGIT_MAX USHRT_MAX +-#define MP_WORD_BIT (CHAR_BIT*sizeof(mp_word)) +-#define MP_WORD_MAX UINT_MAX ++#if HAVE_USUPERLONG_T && HAVE_ULONGLONG_T && \ ++ SIZEOF_SUPERLONG_T / 2 == SIZEOF_LONGLONG_T && \ ++ SIZEOF_PTR >= SIZEOF_LONGLONG_T ++ typedef ulonglong_t mp_digit; ++ typedef usuperlong_t mp_word; ++ #define MP_DIGIT_SIZE SIZEOF_LONGLONG_T ++ #define DIGIT_FMT "%" #SIZEOF_SUPERLONG_T "llx" ++#elif HAVE_ULONGLONG_T && SIZEOF_LONGLONG_T / 2 == SIZEOF_LONG && \ ++ SIZEOF_PTR >= SIZEOF_LONG ++ typedef unsigned long mp_digit; ++ typedef ulonglong_t mp_word; ++ #define MP_DIGIT_SIZE SIZEOF_LONG_T ++ #define DIGIT_FMT "%" #SIZEOF_LONGLONG_T "lx" ++#elif HAVE_ULONGLONG_T && SIZEOF_LONGLONG_T / 2 == SIZEOF_INT && \ ++ SIZEOF_PTR >= SIZEOF_INT ++ typedef unsigned int mp_digit; ++ typedef ulonglong_t mp_word; ++ #define MP_DIGIT_SIZE SIZEOF_INT ++ #define DIGIT_FMT "%" #SIZEOF_LONGLONG_T "lx" ++#elif SIZEOF_LONG / 2 == SIZEOF_INT && SIZEOF_PTR >= SIZEOF_INT ++ typedef unsigned int mp_digit; ++ typedef unsigned long mp_word; ++ #define MP_DIGIT_SIZE SIZEOF_INT ++ #define DIGIT_FMT "%" #SIZEOF_LONG "x" ++#elif SIZEOF_INT / 2 == SIZEOF_SHORT ++ typedef unsigned short mp_digit; ++ typedef unsigned int mp_word; ++ #define DIGIT_FMT "%" #SIZEOF_INT "x" ++#elif SIZEOF_SHORT == 2 ++ typedef unsigned char mp_digit; ++ typedef unsigned short mp_word; ++ #define DIGIT_FMT "%" #SIZEOF_SHORT "x" ++#else ++ #error Failure to configure MPI types on this target platform ++#endif + +-#define RADIX (MP_DIGIT_MAX+1) ++#define MP_DIGIT_BIT ((int) (CHAR_BIT*sizeof(mp_digit))) ++#define MP_DIGIT_MAX ((mp_digit) -1) ++#define MP_WORD_BIT ((int) (CHAR_BIT*sizeof(mp_word))) ++#define MP_WORD_MAX ((mp_word) -1) + +-#define MP_DIGIT_SIZE 2 +-#define DIGIT_FMT "%04X" ++#define RADIX (((mp_word) MP_DIGIT_MAX) + 1) +Index: mpi-1.8.6/mpi.c +=================================================================== +--- mpi-1.8.6.orig/mpi.c 2011-12-09 09:00:59.000000000 -0800 ++++ mpi-1.8.6/mpi.c 2011-12-09 14:10:29.000000000 -0800 +@@ -9,6 +9,7 @@ + $Id: mpi.c,v 1.1 2004/02/08 04:29:29 sting Exp $ + */ + ++#include "../config.h" + #include "mpi.h" + #include <stdlib.h> + #include <string.h> +Index: mpi-1.8.6/mplogic.c +=================================================================== +--- mpi-1.8.6.orig/mplogic.c 2011-12-09 09:00:59.000000000 -0800 ++++ mpi-1.8.6/mplogic.c 2011-12-09 14:10:29.000000000 -0800 +@@ -9,6 +9,7 @@ + $Id: mplogic.c,v 1.1 2004/02/08 04:29:29 sting Exp $ + */ + ++#include "../config.h" + #include "mplogic.h" + #include <stdlib.h> + +Index: mpi-1.8.6/mpprime.c +=================================================================== +--- mpi-1.8.6.orig/mpprime.c 2011-12-09 09:00:59.000000000 -0800 ++++ mpi-1.8.6/mpprime.c 2011-12-09 09:01:01.000000000 -0800 +@@ -10,6 +10,7 @@ + $Id: mpprime.c,v 1.1 2004/02/08 04:29:29 sting Exp $ + */ + ++#include "../config.h" + #include "mpprime.h" + #include <stdlib.h> + +Index: mpi-1.8.6/mprsa.c +=================================================================== +--- mpi-1.8.6.orig/mprsa.c 2011-12-09 09:00:59.000000000 -0800 ++++ mpi-1.8.6/mprsa.c 2011-12-09 09:01:01.000000000 -0800 +@@ -11,6 +11,7 @@ + $Id: mprsa.c,v 1.1 2004/02/08 04:29:29 sting Exp $ + */ + ++#include "../config.h" + #include "mprsa.h" + #include <stdlib.h> + #include <string.h> |