Changeset 15628


Ignore:
Timestamp:
Jan 31, 2013, 8:45:24 PM (6 years ago)
Author:
gb
Message:

Work around Linux libm lossage: recent versions of #_exp/
#_expf don't set overflow bit in fp status reg.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/level-1/l1-numbers.lisp

    r14445 r15628  
    762762  (with-stack-double-floats ((temp))
    763763    #+arm-target (%set-fpscr-status 0)
     764    #+linux-target
     765    (progn
     766      (%get-errno)                      ;clear errno
     767      (#_feclearexcept #$FE_ALL_EXCEPT))
    764768    #-freebsdx8632-target
    765769    (%setf-double-float TEMP (#_exp n))
     
    767771    (%setf-double-float TEMP (external-call "__ieee754_exp" :double-float n :double-float))
    768772    (%df-check-exception-1 'exp n (%ffi-exception-status))
     773    #+linux-target
     774    (and (eql (- #$ERANGE) (%get-errno))
     775         (#_fetestexcept #$FE_OVERFLOW)
     776         (get-fpu-mode :overflow)
     777         (error 'floating-point-overflow
     778                :operation 'exp
     779                :operands (list n)))
    769780    (%setf-double-float result TEMP)))
    770781
     
    774785  (target::with-stack-short-floats ((temp))
    775786    #+arm-target (%set-fpscr-status 0)
     787    #+linux-target
     788    (progn
     789      (%get-errno)                      ;clear errno
     790      (#_feclearexcept #$FE_ALL_EXCEPT))
    776791    #-freebsdx8632-target
    777792    (%setf-short-float TEMP (#_expf n))
     
    779794    (%setf-short-float TEMP (external-call "__ieee754_expf" :single-float n :single-float))
    780795    (%sf-check-exception-1 'exp n (%ffi-exception-status))
     796    #+linux-target
     797    (and (eql (- #$ERANGE) (%get-errno))
     798         (#_fetestexcept #$FE_OVERFLOW)
     799         (get-fpu-mode :overflow)
     800         (error 'floating-point-overflow
     801                :operation 'exp
     802                :operands (list n)))
    781803    (%setf-short-float result TEMP)))
    782804
     
    792814(defun %single-float-exp (n)
    793815  (declare (single-float n))
     816  #+linux-target
     817  (progn
     818    (%get-errno)                      ;clear errno
     819    (#_feclearexcept #$FE_ALL_EXCEPT))
    794820  (let* ((result (#_expf n)))
    795821    (%sf-check-exception-1 'exp n (%ffi-exception-status))
     822    #+linux-target
     823    (and (eql (- #$ERANGE) (%get-errno))
     824         (#_fetestexcept #$FE_OVERFLOW)
     825         (get-fpu-mode :overflow)
     826         (error 'floating-point-overflow
     827                :operation 'exp
     828                :operands (list n)))
    796829    result))
    797830
Note: See TracChangeset for help on using the changeset viewer.