summaryrefslogtreecommitdiffstats
path: root/mpi-patches
Commit message (Collapse)AuthorAgeFilesLines
* * mpi-patches/config-types: Include the header as "config.h"Kaz Kylheku2012-10-301-4/+4
| | | | | | | | rather than "../config.h" because the dependency generation script checks for this as a special case and treats it relative to the build directory. * dep.mk: Regenerated.
* * arith.c (highest_significant_bit): New static function.Kaz Kylheku2012-09-171-7/+110
| | | | | | | | | | | | | | | | (comp_clamp): Bugfix: avoid shifting left into sign bit. Function renamed to comp_trunc. (logtrunc, ash): New functions. * eval.c (eval_init): Registered logtrunc and ash intrinsics. * lib.h (logtrunc, ash): Declared. * mpi-patches/add-bitops (s_highest_bit_mp): Forward declaration for added. (mp_clamp_comp): Bugfix in handling remainder bits. Function renamed to mp_trunc_comp. (mp_trunc, mp_shift): New functions.
* * mpi-patches/add-bitops: Bugfixes: mp_2comp is extended to properlyKaz Kylheku2012-09-161-13/+17
| | | | | | | | allow arbitrarily wide complements (which causes the code to access beyond the a argument's digits array). A similar fix is applied in the new mp_clamp_comp function. Incorrect initializations of mp_int fixed in all the logic functions: mp_init was used instead of mp_init_size.
* * arith.c (logand, logior, logxor): Bugfix: result needs to beKaz Kylheku2012-09-161-4/+47
| | | | | | | | | | | | | | normalized, otherwise we end up with fixnum-range bignums. (comp_clamp): New function. (logcomp): Changed to two argument form. If second argument is present (not nil) then call comp_clamp. * eval.c (eval_init): Change registration of logcomp to allow optional argument. * lib.h (logcomp): Declaration updated. * mpi-patches/add-bitops: New mp_clamp_comp function implemented.
* Adding complementing function.Kaz Kylheku2012-09-161-7/+51
| | | | | | | | | | * arith.c (logcomp): New function. * eval.c (eval_init): logcomp registered as intrinsic. * lib.h (logcomp) declared. * mpi-patches/add-bitops: Fixed bugs in mp_xor. Implemented mp_comp.
* Starting work on adding bit operations. The semantics is thatKaz Kylheku2012-09-162-0/+274
| | | | | | | | | | | | | | negative integers behave as an "infinite bit two's complement". * arith.c (logand, logor, logxor): New functions. * eval.c (eval_init): New intrinsic functions logand, logior, logxor. * lib.h (logand, logor, logxor): Declared. * mpi-patches/series: New patch, add-bitops. * mpi-patches/add-bitops: New file.
* Adding patch to MPI to disable its Makefile so people don't tryKaz Kylheku2012-04-103-0/+51
| | | | | | | | | | | | | | to work around TXR build problems by running make inside the MPI directory, which is wrong. Also fixing an incorrect use of ctype.h functions in MPI and one case of a superfluous warning. * mpi-patches/series: new patches added. * mpi-patches/disable-make: New file. * mpi-patches/fix-ctype-warnings: New file.
* * mpi-patches/add-mp-hash (mp_hash): Fix incorrectKaz Kylheku2012-04-091-6/+6
| | | | | | | | code on platforms where mp_digit is smaller than long. This was left shifting a mp_digit by MP_DIGIT_BIT. It was found by compiling on NetBSD with a gcc 4.1.3 which has a broken__int128_t, forcing us to use 32 bit mp_digit with a 64 bit mp_word.
* * arith.c (plus): Minor code simplification.Kaz Kylheku2012-03-211-5/+5
| | | | | | | | (minus): Floating point support. * mpi-patches/mpi-to-double (mp_to_double): Re-apply lost bugfix: index incremented instead of decremented. Didn't refresh patch last time, then did a make distclean.
* * arith.c (flo_int): New function.Kaz Kylheku2012-03-202-0/+59
| | | | | | | | | | | * eval.c (eval_init): flo-int registered as intrinsic. * lib.h (flo_int): Declared. * mpi-patches/series: Added mpi-to-double to patch stack. (mp_to_double): New MPI function. * mpi-patches/mpi-to-double: New file.
* * mpi-patches/add-mp-hash (mp_hash): Fixed use of uninitializedKaz Kylheku2012-03-046-41/+54
| | | | | | | | | | | | | | | | | | variable on platforms where the MP digit is smaller than a long integer. (Not anything TXR is known to run on). Changed algorithm to take the first and last digit and add them together, rather than just taking the last digit. The last digit will be zeros for numbers that contain 2 as a factor with a large enough multiplicity. * mpi-patches/add-mpi-toradix-with-case: Refreshed. * mpi-patches/bit-search-optimizations: Likewise. * mpi-patches/faster-square-root: Likewise. * mpi-patches/fix-bad-shifts: Likewise. * mpi-patches/fix-mult-bug: Likewise.
* * mpi-patches/shrink-mpi-int (mpi_int): Fixed terrible bug in thisKaz Kylheku2011-12-271-8/+6
| | | | | patch, resulting in an insufficient bit field width for representing the allocation size of the MPI integer on 32 bit platforms.
* * mpi-patches/bit-search-optimizations (s_highest_bit):Kaz Kylheku2011-12-211-13/+13
| | | | | | It will take days to completely wipe the egg off my face. I forgot to fix this code for unsigned integers before pasting it into MPI.
* * arith.c (highest_bit): Linkage changed to static.Kaz Kylheku2011-12-132-0/+184
| | | | | | | | | | | | | | | | | (abso, isqrt): New functions. (isqrt_fixnum): New static function. * eval.c (eval_init): Registered abs, sqrt and numberp instrinsics. * lib.c (numberp): New function. * lib.h (numberp, abso, isqrt): Declared. * mpi-patches/series: New patch added. * mpi-patches/faster-square-root: New patch added. * txr.1: Documentation stubs for new functions.
* Patch to shrink mpi-int to three words on 32 bit platforms,Kaz Kylheku2011-12-132-0/+21
| | | | | | | | so that obj_t stays four pointers wide. * mpi-patches/series: New patch added. * mpi-patches/shrink-mpi-int: New file.
* * mpi-patches/bit-search-optimizations (s_highest_bit): Added staticKaz Kylheku2011-12-122-4/+31
| | | | | | | | | storage class specifier. * mpi-patches/fix-mult-bug (s_mp_sqr): More braindamage found in MPI. This function performs additions and multiplication mp_digit, expecting a mp_word precision result without casting. This function is needed for exponentiation.
* Git rid of some some loops in MPI where it is searching forKaz Kylheku2011-12-122-0/+301
| | | | | | | | | the highest bit, replacing them with an adapation of the bit searching function used in arith.c. * mpi-patches/series: Patch added. * mpi-patches/bit-search-optimizations: New file.
* * mpi-patches/fix-mult-bug: One more flaw discovered inKaz Kylheku2011-12-122-2/+12
| | | | | | | | | | | | s_mp_mul_d and added to patch. This one caused malloc corruption and crashes, because the incorrect arithmetic causes the function to think that the multiplication will not be needing another digit, but then there is a carry out which does spill into a new digit. * mpi-patches/series: Arg! Somehow the patch fix-bad-shift went missing from the series file, even though the patch itself is in the GIT repository.
* Bignum division implemented. More portability bugs found in MPI:Kaz Kylheku2011-12-111-0/+49
| | | | | | | | | | | code like 1 << n, where n exceeds the width of the type int. * arith.c (trunc): New function, reimplementation of removed trunc from lib.c. * lib.c (trunc): Removed. * mpi-patches/fix-bad-shifts: New file.
* Bignum support in mult function.Kaz Kylheku2011-12-103-18/+27
| | | | | | | | | | | | | | | | | | | | | | * arith.c: Regenerated. * arith.txr (CNUM_BIT): New constant. (bignum, bignum_dbl_ipt): New static functions. (@{add-fname}): Use bignum function. (mul): New functions, rewrite of mul from lib.c. * lib.c (mul): Function removed. * mpi-patches/add-mp-set-intptr (mp_set_intptr): Revised patch. Local variable v should be int_ptr_t not unsigned long. Also, the mp_set interface doesn't set the sign; it's an unsigned interface. We must do that ourselves. * mpi-patches/fix-mult-bug: The main multiplication function is also broken in the same way, requiring the cast. * mpi-patches/mpi-set-double-intptr: Fixed use of wrong type for local variable v.
* * mpi-patches/mpi-set-mpi-word: Bugfix and refresh.Kaz Kylheku2011-12-103-4/+60
| | | | | | * mpi-patches/mpi-set-double-intptr: New file. * mpi-patches/series (mpi-set-double-intptr): Patch added.
* Adding mp_set_word function.Kaz Kylheku2011-12-102-0/+33
| | | | | | * mpi-patches/series (mpi-set-mpi-word): New patch. * mpi-patches/mpi-set-mpi-word: New file.
* * mpi-patches/add-mp-hash: Rewrote mp_hash to only hash enoughKaz Kylheku2011-12-103-32/+23
| | | | | | | | | | | | | low-order bit material from the bignum to fill an unsigned long. We don't need to walk the entire bignum. If the low order digit of the bignum is at least as large as an unsigned long, we just take that as the hash, otherwise we take enough of the digits to fill an unsigned long. For negative numbers, we just invert the bits of the hash. * mpi-patches/add-mpi-toradix-with-case: Refreshed. * mpi-patches/fix-mult-bug: Refreshed.
* Build and pass test suite on Cygwin.Kaz Kylheku2011-12-091-11/+11
| | | | | | | | | | * configure (longlong, ulonglong, superlong, usuperlong): Initialize these variables so that if the detection tests fail, the script does not access unbound variables. Avoid adding junk like .bss.* into config.h. * mpi-patches/config-types: Fixed wrong use of nonexistent SIZEOF_LONG_T.
* 2011-12-09 Kaz Kylheku <kaz@kylheku.com>Kaz Kylheku2011-12-091-11/+13
| | | | | * mpi-patches/config-types: Added missing definitions of MP_DIGIT_SIZE in two cases.
* Bignum support, here we go!Kaz Kylheku2011-12-099-0/+485
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.