Raymond Toy pushed to branch master at cmucl / cmucl Commits: 3b80b535 by Raymond Toy at 2026-03-02T11:28:59-08:00 Fix #484: Use openlibm single-float functions for lisp - - - - - 66c5af54 by Raymond Toy at 2026-03-02T11:28:59-08:00 Merge branch 'issue-484-use-openlibm' into 'master' Fix #484: Use openlibm single-float functions for lisp Closes #484 and #485 See merge request cmucl/cmucl!362 - - - - - 3 changed files: - src/lisp/Config.x86_common - src/lisp/GNUmakefile - src/lisp/irrat.c Changes: ===================================== src/lisp/Config.x86_common ===================================== @@ -95,10 +95,49 @@ CORE_MATH_SRCS = $(CORE64_SRCS) $(CORE32_SRCS) endif +# If core-math is not defined such as on Darwin, we use the code from +# openlibm to implement the special functions for single-floats. +ifndef FEATURE_CORE_MATH +OPENLIBM_DIR = openlibm +OPENLIBM_SRCS = \ + $(OPENLIBM_DIR)/e_acosf.c \ + $(OPENLIBM_DIR)/e_acoshf.c \ + $(OPENLIBM_DIR)/e_asinf.c \ + $(OPENLIBM_DIR)/e_atan2f.c \ + $(OPENLIBM_DIR)/e_atanhf.c \ + $(OPENLIBM_DIR)/e_coshf.c \ + $(OPENLIBM_DIR)/e_expf.c \ + $(OPENLIBM_DIR)/e_hypotf.c \ + $(OPENLIBM_DIR)/e_log10f.c \ + $(OPENLIBM_DIR)/e_logf.c \ + $(OPENLIBM_DIR)/e_powf.c \ + $(OPENLIBM_DIR)/e_rem_pio2f.c \ + $(OPENLIBM_DIR)/e_sinhf.c \ + $(OPENLIBM_DIR)/k_cosf.c \ + $(OPENLIBM_DIR)/k_sinf.c \ + $(OPENLIBM_DIR)/k_tanf.c \ + $(OPENLIBM_DIR)/k_expf.c \ + $(OPENLIBM_DIR)/s_asinhf.c \ + $(OPENLIBM_DIR)/s_atanf.c \ + $(OPENLIBM_DIR)/s_cosf.c \ + $(OPENLIBM_DIR)/s_expm1f.c \ + $(OPENLIBM_DIR)/s_log1pf.c \ + $(OPENLIBM_DIR)/s_sinf.c \ + $(OPENLIBM_DIR)/s_sincosf.c \ + $(OPENLIBM_DIR)/s_tanf.c \ + $(OPENLIBM_DIR)/s_tanhf.c +endif + ifeq ($(filter 2% 3%, $(shell $(CC) -dumpversion)),) CPP_INCLUDE_OPTIONS := -iquote . -iquote $(PATH1) +ifndef FEATURE_CORE_MATH +CPP_INCLUDE_OPTIONS += -I $(PATH1)/$(OPENLIBM_DIR) -DOPENLIBM_USE_HOST_MATH_H +endif else -CPP_INCLUDE_OPTIONS := -I. -I$(PATH1) -I- +CPP_INCLUDE_OPTIONS := -I. -I$(PATH1) -I $(OPENLIBM_DIR) -I- +ifndef FEATURE_CORE_MATH +CPP_INCLUDE_OPTIONS += -I $(PATH1)/$(OPENLIBM_DIR) +endif endif CPPFLAGS := $(CPP_DEFINE_OPTIONS) $(CPP_INCLUDE_OPTIONS) ===================================== src/lisp/GNUmakefile ===================================== @@ -37,6 +37,7 @@ SRCS = lisp.c coreparse.c alloc.c monitor.c print.c interr.c \ runprog.c time.c case-mapping.c exec-init.c \ irrat.c \ ${CORE_MATH_SRCS} \ + ${OPENLIBM_SRCS} \ ${FDLIBM} ${ARCH_SRC} ${ASSEM_SRC} ${OS_SRC} ${GC_SRC} ===================================== src/lisp/irrat.c ===================================== @@ -54,6 +54,8 @@ extern float cr_hypotf(float, float); extern float cr_log1pf(float); extern float cr_expm1f(float); extern void cr_sincosf(float, float *, float *); +#else +#include "openlibm_math.h" #endif @@ -348,7 +350,7 @@ lisp_sinf(float x) #ifdef FEATURE_CORE_MATH return cr_sinf(x); #else - return (float) fdlibm_sin((double) x); + return sinf(x); #endif } @@ -358,7 +360,7 @@ lisp_cosf(float x) #ifdef FEATURE_CORE_MATH return cr_cosf(x); #else - return (float) fdlibm_cos((double) x); + return cosf(x); #endif } @@ -368,7 +370,7 @@ lisp_tanf(float x) #ifdef FEATURE_CORE_MATH return cr_tanf(x); #else - return (float) fdlibm_tan((double) x); + return tanf(x); #endif } @@ -378,7 +380,7 @@ lisp_atanf(float x) #ifdef FEATURE_CORE_MATH return cr_atanf(x); #else - return (float) fdlibm_atan((double) x); + return atanf(x); #endif } @@ -388,7 +390,7 @@ lisp_atan2f(float y, float x) #ifdef FEATURE_CORE_MATH return cr_atan2f(y, x); #else - return (float) __ieee754_atan2((double) y, (double) x); + return atan2f(y, x); #endif } @@ -398,7 +400,7 @@ lisp_asinf(float x) #ifdef FEATURE_CORE_MATH return cr_asinf(x); #else - return (float) __ieee754_asin((double) x); + return asinf(x); #endif } @@ -408,7 +410,7 @@ lisp_acosf(float x) #ifdef FEATURE_CORE_MATH return cr_acosf(x); #else - return (float) __ieee754_acos((double) x); + return acosf(x); #endif } @@ -418,7 +420,7 @@ lisp_sinhf(float x) #ifdef FEATURE_CORE_MATH return cr_sinhf(x); #else - return (float) __ieee754_sinh((double) x); + return sinhf(x); #endif } @@ -428,7 +430,7 @@ lisp_coshf(float x) #ifdef FEATURE_CORE_MATH return cr_coshf(x); #else - return (float) __ieee754_cosh((double) x); + return coshf(x); #endif } @@ -438,7 +440,7 @@ lisp_tanhf(float x) #ifdef FEATURE_CORE_MATH return cr_tanhf(x); #else - return (float) fdlibm_tanh((double) x); + return tanhf(x); #endif } @@ -448,7 +450,7 @@ lisp_asinhf(float x) #ifdef FEATURE_CORE_MATH return cr_asinhf(x); #else - return (float) fdlibm_asinh((double) x); + return asinhf((double) x); #endif } @@ -458,7 +460,7 @@ lisp_acoshf(float x) #ifdef FEATURE_CORE_MATH return cr_acoshf(x); #else - return (float) __ieee754_acosh((double) x); + return acoshf(x); #endif } @@ -468,7 +470,7 @@ lisp_atanhf(float x) #ifdef FEATURE_CORE_MATH return cr_atanhf(x); #else - return (float) __ieee754_atanh((double) x); + return atanhf(x); #endif } @@ -478,7 +480,7 @@ lisp_expf(float x) #ifdef FEATURE_CORE_MATH return cr_expf(x); #else - return (float) __ieee754_exp((double) x); + return expf(x); #endif } @@ -488,7 +490,7 @@ lisp_logf(float x) #ifdef FEATURE_CORE_MATH return cr_logf(x); #else - return (float) __ieee754_log((double) x); + return log(x); #endif } @@ -498,7 +500,7 @@ lisp_log10f(float x) #ifdef FEATURE_CORE_MATH return cr_log10f(x); #else - return (float) __ieee754_log10((double) x); + return log10f(x); #endif } @@ -520,7 +522,7 @@ lisp_powf(float x, float y) * just use fdlibm for now until we can figure out what's causing * the failure. */ - return (float) __ieee754_pow((double) x, (double) y); + return pow(x, y); #endif } @@ -530,7 +532,7 @@ lisp_hypotf(float x, float y) #ifdef FEATURE_CORE_MATH return cr_hypotf(x, y); #else - return (float) __ieee754_hypot((double) x, (double) y); + return hypotf(x, y); #endif } @@ -540,7 +542,7 @@ lisp_log1pf(float x) #ifdef FEATURE_CORE_MATH return cr_log1pf(x); #else - return (float) fdlibm_log1p((double) x); + return log1pf(x); #endif } @@ -550,7 +552,7 @@ lisp_expm1f(float x) #ifdef FEATURE_CORE_MATH return cr_expm1f(x); #else - return (float) fdlibm_expm1((double) x); + return expm1f(x); #endif } @@ -560,11 +562,8 @@ lisp_sincosf(float x, float *s, float *c) #ifdef FEATURE_CORE_MATH cr_sincosf(x, s, c); #else - extern void cmucl_sincos(double, double*, double*); - double ds, dc; - - cmucl_sincos((double) x, &ds, &dc); - *s = (float) ds; - *c = (float) dc; + extern void sincosf(float x, float *s, float *c); + + sincosf(x, s, c); #endif } View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/0418eaf3371f98d907dfd94... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/0418eaf3371f98d907dfd94... You're receiving this email because of your account on gitlab.common-lisp.net.
participants (1)
-
Raymond Toy (@rtoy)