diff --git a/src/lisp/num_gmp.lisp b/src/lisp/num_gmp.lisp index b58001e0b..f4a022ad4 100644 --- a/src/lisp/num_gmp.lisp +++ b/src/lisp/num_gmp.lisp @@ -646,14 +646,27 @@ (setf (symbol-function 'orig-isqrt) (symbol-function 'common-lisp:isqrt))) +(defmacro negate_bignum(x) + (let ((sym2 + (find-symbol "NEGATE-BIGNUM-NOT-FULLY-NORMALIZED" "SB-BIGNUM"))) + (if sym2 + `(,sym2 ,x) + ;;; 'read-from-string' looks silly, but here we want error + ;;; if NEGATE-BIGNUM is absent from SB-BIGNUM + (let ((sym1 (read-from-string "SB-BIGNUM::NEGATE-BIGNUM"))) + `(,sym1 ,x nil)) + ) + ) +) + (defun gmp-multiply-bignums0 (a b) ;;; (declare (type bignum-type a b)) (let* ((a-plusp (sb-bignum::%bignum-0-or-plusp a (sb-bignum::%bignum-length a))) (b-plusp (sb-bignum::%bignum-0-or-plusp b (sb-bignum::%bignum-length b))) - (a (if a-plusp a (sb-bignum::negate-bignum a))) - (b (if b-plusp b (sb-bignum::negate-bignum b))) + (a (if a-plusp a (negate_bignum a))) + (b (if b-plusp b (negate_bignum b))) (len-a (sb-bignum::%bignum-length a)) (len-b (sb-bignum::%bignum-length b)) (len-res (+ len-a len-b)) @@ -697,10 +710,10 @@ (let* ( (nx (if (sb-bignum::%bignum-0-or-plusp x (sb-bignum::%bignum-length x)) (sb-bignum::copy-bignum x) - (sb-bignum::negate-bignum x nil))) + (negate_bignum x))) (ny (if (sb-bignum::%bignum-0-or-plusp y (sb-bignum::%bignum-length y)) (sb-bignum::copy-bignum y) - (sb-bignum::negate-bignum y nil))) + (negate_bignum y))) (xl (sb-bignum::%bignum-length nx)) (yl (sb-bignum::%bignum-length ny)) (rl (if (< xl yl) xl yl)) @@ -735,9 +748,9 @@ (x-plusp (sb-bignum::%bignum-0-or-plusp x (sb-bignum::%bignum-length x))) (y-plusp (sb-bignum::%bignum-0-or-plusp y (sb-bignum::%bignum-length y))) (nx (if x-plusp x - (sb-bignum::negate-bignum x nil))) + (negate_bignum x))) (ny (if y-plusp y - (sb-bignum::negate-bignum y nil))) + (negate_bignum y))) (len-x (sb-bignum::%bignum-length nx)) (len-y (sb-bignum::%bignum-length ny)) (q nil)