X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcode%2Firrat.lisp;h=1b28a3a295a074271984cde6c3ed19289408adb8;hb=dafa18aa6bd65fe2129a32b0e827141684bb159a;hp=55dbb831a1d2bf5ea1ed8eace0b6125c4f3da7d9;hpb=9510443d0bd00fcbd0213e07a5340e66d9ce7301;p=sbcl.git diff --git a/src/code/irrat.lisp b/src/code/irrat.lisp index 55dbb83..1b28a3a 100644 --- a/src/code/irrat.lisp +++ b/src/code/irrat.lisp @@ -23,15 +23,18 @@ (eval-when (:compile-toplevel :execute) (sb!xc:defmacro def-math-rtn (name num-args) - (let ((function (symbolicate "%" (string-upcase name)))) + (let ((function (symbolicate "%" (string-upcase name))) + (args (let ((sb!impl::*gentemp-counter* 0)) + (loop repeat num-args collect (gentemp "ARG"))))) `(progn (declaim (inline ,function)) - (sb!alien:define-alien-routine (,name ,function) double-float - ,@(let ((results nil)) - (dotimes (i num-args (nreverse results)) - (push (list (intern (format nil "ARG-~D" i)) - 'double-float) - results))))))) + (defun ,function ,args + (alien-funcall + (extern-alien ,name + (function double-float + ,@(loop repeat num-args + collect 'double-float))) + ,@args))))) (defun handle-reals (function var) `((((foreach fixnum single-float bignum ratio)) @@ -178,10 +181,15 @@ #!+sb-doc "Return BASE raised to the POWER." (if (zerop power) - (let ((result (1+ (* base power)))) - (if (and (floatp result) (float-nan-p result)) - (float 1 result) - result)) + (if (and (zerop base) (floatp power)) + (error 'arguments-out-of-domain-error + :operands (list base power) + :operation 'expt + :references (list '(:ansi-cl :function expt))) + (let ((result (1+ (* base power)))) + (if (and (floatp result) (float-nan-p result)) + (float 1 result) + result))) (labels (;; determine if the double float is an integer. ;; 0 - not an integer ;; 1 - an odd int