[Git][cmucl/cmucl][issue-435-add-core-math-lisp-support] For darwin, explicitly signal overflow in lisp_expf
Raymond Toy pushed to branch issue-435-add-core-math-lisp-support at cmucl / cmucl Commits: 2ce06664 by Raymond Toy at 2026-02-28T07:42:43-08:00 For darwin, explicitly signal overflow in lisp_expf On darwin, lisp_expf isn't signaling overflow when the arg is too large. To fix this, save the value from __ieee754_exp. Then check to see it's too large to fit in a single-float and signal an overflow if so. Otherwise, just convert the value to a float and return it. This should fix ansi-test failures for EXP.ERROR.4 and EXP.ERROR.5 on darwin. We'll probably need to do the same thing for the other single-float functions that can overflow on Darwin. - - - - - 1 changed file: - src/lisp/irrat.c Changes: ===================================== src/lisp/irrat.c ===================================== @@ -73,6 +73,16 @@ extern float cr_log2f(float); return fdlibm_setexception(x, FDLIBM_OVERFLOW); \ } +#ifdef DARWIN +#define DARWIN_SINGLE_FLOAT_OVERFLOW(y) \ + do { \ + if (fabs(y) >= 0x1.0p128) { \ + return fdlibm_setexception(y, FDLIBM_OVERFLOW); \ + } \ + } while (0) + +#endif + double lisp_sin(double x) { @@ -483,9 +493,17 @@ lisp_expf(float x) { #ifdef FEATURE_CORE_MATH return cr_expf(x); -#else +#else +#if defined(DARWIN) + double y = __ieee754_exp((double) x); + + DARWIN_SINGLE_FLOAT_OVERFLOW(y); + + return (float) y; +#else return (float) __ieee754_exp((double) x); #endif +#endif } float View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/2ce06664397eeaa5de655708... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/2ce06664397eeaa5de655708... You're receiving this email because of your account on gitlab.common-lisp.net.
participants (1)
-
Raymond Toy (@rtoy)