Raymond Toy pushed to branch master at cmucl / cmucl Commits: 7f708431 by Raymond Toy at 2026-01-27T08:45:32-08:00 Fix #466: Add C wrapper for the special functions - - - - - 318d0560 by Raymond Toy at 2026-01-27T08:45:32-08:00 Merge branch 'issue-466-c-wrapper-specfun' into 'master' Fix #466: Add C wrapper for the special functions Closes #466 See merge request cmucl/cmucl!345 - - - - - 5 changed files: - src/code/irrat.lisp - src/lisp/GNUmakefile - src/lisp/fdlibm.h - + src/lisp/irrat.c - src/lisp/log2.c Changes: ===================================== src/code/irrat.lisp ===================================== @@ -76,37 +76,37 @@ ;;; Please refer to the Unix man pages for details about these routines. ;;; Trigonometric. -(def-math-rtn ("fdlibm_sin" %sin) 1) -(def-math-rtn ("fdlibm_cos" %cos) 1) -(def-math-rtn ("fdlibm_tan" %tan) 1) -(def-math-rtn ("fdlibm_atan" %atan) 1) -(def-math-rtn ("__ieee754_atan2" %atan2) 2) -(def-math-rtn ("__ieee754_asin" %asin) 1) -(def-math-rtn ("__ieee754_acos" %acos) 1) -(def-math-rtn ("__ieee754_sinh" %sinh) 1) -(def-math-rtn ("__ieee754_cosh" %cosh) 1) -(def-math-rtn ("fdlibm_tanh" %tanh) 1) -(def-math-rtn ("fdlibm_asinh" %asinh) 1) -(def-math-rtn ("__ieee754_acosh" %acosh) 1) -(def-math-rtn ("__ieee754_atanh" %atanh) 1) +(def-math-rtn ("lisp_sin" %sin) 1) +(def-math-rtn ("lisp_cos" %cos) 1) +(def-math-rtn ("lisp_tan" %tan) 1) +(def-math-rtn ("lisp_atan" %atan) 1) +(def-math-rtn ("lisp_atan2" %atan2) 2) +(def-math-rtn ("lisp_asin" %asin) 1) +(def-math-rtn ("lisp_acos" %acos) 1) +(def-math-rtn ("lisp_sinh" %sinh) 1) +(def-math-rtn ("lisp_cosh" %cosh) 1) +(def-math-rtn ("lisp_tanh" %tanh) 1) +(def-math-rtn ("lisp_asinh" %asinh) 1) +(def-math-rtn ("lisp_acosh" %acosh) 1) +(def-math-rtn ("lisp_atanh" %atanh) 1) ;;; Exponential and Logarithmic. -(def-math-rtn ("__ieee754_exp" %exp) 1) -(def-math-rtn ("__ieee754_log" %log) 1) -(def-math-rtn ("__ieee754_log10" %log10) 1) -(def-math-rtn ("cmucl_log2" %log2) 1) +(def-math-rtn ("lisp_exp" %exp) 1) +(def-math-rtn ("lisp_log" %log) 1) +(def-math-rtn ("lisp_log10" %log10) 1) +(def-math-rtn ("lisp_log2" %log2) 1) -(def-math-rtn ("__ieee754_pow" %pow) 2) +(def-math-rtn ("lisp_pow" %pow) 2) #-(or x86 sparc-v7 sparc-v8 sparc-v9) (def-math-rtn "sqrt" 1) -(def-math-rtn ("__ieee754_hypot" %hypot) 2) +(def-math-rtn ("lisp_hypot" %hypot) 2) -(def-math-rtn ("fdlibm_log1p" %log1p) 1) -(def-math-rtn ("fdlibm_expm1" %expm1) 1) +(def-math-rtn ("lisp_log1p" %log1p) 1) +(def-math-rtn ("lisp_expm1" %expm1) 1) (declaim (inline %scalbn)) (export '%scalbn) -(alien:def-alien-routine ("fdlibm_scalbn" %scalbn) c-call:double +(alien:def-alien-routine ("lisp_scalbn" %scalbn) c-call:double (x double-float) (n c-call:int)) ===================================== src/lisp/GNUmakefile ===================================== @@ -35,6 +35,7 @@ SRCS = lisp.c coreparse.c alloc.c monitor.c print.c interr.c \ vars.c parse.c interrupt.c search.c validate.c globals.c \ dynbind.c breakpoint.c regnames.c backtrace.c save.c purify.c \ runprog.c time.c case-mapping.c exec-init.c \ + irrat.c \ ${FDLIBM} ${ARCH_SRC} ${ASSEM_SRC} ${OS_SRC} ${GC_SRC} OBJS = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(patsubst %.s,%.o,$(SRCS)))) ===================================== src/lisp/fdlibm.h ===================================== @@ -54,8 +54,21 @@ extern double fdlibm_tan(double x); extern double fdlibm_expm1(double x); extern double fdlibm_log1p(double x); extern double fdlibm_atan(double x); +extern double fdlibm_tanh(double x); +extern double fdlibm_asinh(double x); extern double __ieee754_exp(double x); extern double __ieee754_log(double x); +extern double __ieee754_atan2(double y, double x); +extern double __ieee754_asin(double x); +extern double __ieee754_acos(double x); +extern double __ieee754_sinh(double x); +extern double __ieee754_cosh(double x); +extern double __ieee754_atanh(double x); +extern double __ieee754_acosh(double x); +extern double __ieee754_log10(double x); +extern double __ieee754_pow(double x, double y); +extern double __ieee754_hypot(double x, double y); +extern double fdlibm_scalbn(double x, int n); enum FDLIBM_EXCEPTION { FDLIBM_DIVIDE_BY_ZERO, ===================================== src/lisp/irrat.c ===================================== @@ -0,0 +1,138 @@ +/* + + This code was written as part of the CMU Common Lisp project at + Carnegie Mellon University, and has been placed in the public domain. + +*/ + +#include "fdlibm.h" + +/* + * Wrappers for the special functions + */ + +double +lisp_sin(double x) +{ + return fdlibm_sin(x); +} + +double +lisp_cos(double x) +{ + return fdlibm_cos(x); +} + +double +lisp_tan(double x) +{ + return fdlibm_tan(x); +} + +double +lisp_atan(double x) +{ + return fdlibm_atan(x); +} + +double +lisp_atan2(double y, double x) +{ + return __ieee754_atan2(y, x); +} + +double +lisp_asin(double x) +{ + return __ieee754_asin(x); +} + +double +lisp_acos(double x) +{ + return __ieee754_acos(x); +} + +double +lisp_sinh(double x) +{ + return __ieee754_sinh(x); +} + +double +lisp_cosh(double x) +{ + return __ieee754_cosh(x); +} + +double +lisp_tanh(double x) +{ + return fdlibm_tanh(x); +} + +double +lisp_asinh(double x) +{ + return fdlibm_asinh(x); +} + +double +lisp_acosh(double x) +{ + return __ieee754_acosh(x); +} + +double +lisp_atanh(double x) +{ + return __ieee754_atanh(x); +} + +double +lisp_exp(double x) +{ + return __ieee754_exp(x); +} + +double +lisp_log(double x) +{ + return __ieee754_log(x); +} + +double +lisp_log10(double x) +{ + return __ieee754_log10(x); +} + +double +lisp_pow(double x, double y) +{ + return __ieee754_pow(x, y); +} + +double +lisp_hypot(double x, double y) +{ + return __ieee754_hypot(x, y); +} + +double +lisp_log1p(double x) +{ + return fdlibm_log1p(x); +} + +double +lisp_expm1(double x) +{ + return fdlibm_expm1(x); +} + +double +lisp_scalbn(double x, int n) +{ + return fdlibm_scalbn(x, n); +} ===================================== src/lisp/log2.c ===================================== @@ -39,7 +39,7 @@ cp = 9.61796693925975554329e-01, /* 0x3FEEC709, 0xDC3A03FD =2/(3ln2) */ cp_h = 9.61796700954437255859e-01, /* 0x3FEEC709, 0xE0000000 =(float)cp */ cp_l = -7.02846165095275826516e-09; /* 0xBE3E2FE0, 0x145B01F5 =tail of cp_h*/ -double cmucl_log2(double x) +double lisp_log2(double x) { double ax; int k, hx, lx, ix; View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/ea927341913119e29bf8919... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/ea927341913119e29bf8919... You're receiving this email because of your account on gitlab.common-lisp.net.
participants (1)
-
Raymond Toy (@rtoy)