From: Chris Hanson Date: Mon, 27 Jun 2011 00:34:34 +0000 (-0700) Subject: Don't use expm1 and log1p unless they're available. X-Git-Tag: release-9.1.0~9 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=0270fb61e9611a0b7ed84fe88e0d320a489efd91;p=mit-scheme.git Don't use expm1 and log1p unless they're available. --- diff --git a/src/microcode/configure.ac b/src/microcode/configure.ac index 642cf04a0..2a032eec0 100644 --- a/src/microcode/configure.ac +++ b/src/microcode/configure.ac @@ -515,6 +515,7 @@ AC_FUNC_VPRINTF AC_FUNC_WAIT3 AC_CHECK_FUNCS([clock_gettime closefrom ctermid]) AC_CHECK_FUNCS([dup2]) +AC_CHECK_FUNCS([expm1]) AC_CHECK_FUNCS([fcntl fdatasync feclearexcept fedisableexcept feenableexcept]) AC_CHECK_FUNCS([fegetenv fegetexcept fegetexceptflag fegetround feholdexcept]) AC_CHECK_FUNCS([feraiseexcept fesetenv fesetexceptflag fesetround]) @@ -523,7 +524,7 @@ AC_CHECK_FUNCS([fpsetround fsync fsync_range ftruncate]) AC_CHECK_FUNCS([getcwd gethostbyname gethostname getlogin getpagesize getpgrp]) AC_CHECK_FUNCS([getpt gettimeofday getwd grantpt]) AC_CHECK_FUNCS([kill]) -AC_CHECK_FUNCS([lockf]) +AC_CHECK_FUNCS([lockf log1p]) AC_CHECK_FUNCS([madvise memcpy mkdir mktime modf]) AC_CHECK_FUNCS([nice ntp_adjtime ntp_gettime]) AC_CHECK_FUNCS([poll posix_madvise prealloc]) diff --git a/src/microcode/flonum.c b/src/microcode/flonum.c index b329015a0..9b4f5e437 100644 --- a/src/microcode/flonum.c +++ b/src/microcode/flonum.c @@ -30,14 +30,6 @@ USA. #include "prims.h" #include -#ifndef M_LN2 -# define M_LN2 0.693147180559945309417232121458176568 /* log e2 */ -#endif - -#ifndef M_SQRT1_2 -# define M_SQRT1_2 0.707106781186547524400844362104849039 /* 1/sqrt(2) */ -#endif - double arg_flonum (int arg_number) { @@ -156,11 +148,26 @@ DEFINE_PRIMITIVE ("FLONUM-NEGATIVE?", Prim_flonum_negative_p, 1, 1, 0) } DEFINE_PRIMITIVE ("FLONUM-EXPM1", Prim_flonum_expm1, 1, 1, 0) +#ifdef HAVE_EXPM1 RESTRICTED_TRANSCENDENTAL_FUNCTION (expm1, ((x >= - M_LN2) && (x <= M_LN2))) +#else +{ + error_unimplemented_primitive (); + PRIMITIVE_RETURN (UNSPECIFIC); +} +#endif + DEFINE_PRIMITIVE ("FLONUM-LOG1P", Prim_flonum_log1p, 1, 1, 0) +#ifdef HAVE_LOG1P RESTRICTED_TRANSCENDENTAL_FUNCTION (log1p, ((x >= (M_SQRT1_2 - 1.0)) && (x <= (1.0 - M_SQRT1_2)))) +#else +{ + error_unimplemented_primitive (); + PRIMITIVE_RETURN (UNSPECIFIC); +} +#endif DEFINE_PRIMITIVE ("FLONUM-EXP", Prim_flonum_exp, 1, 1, 0) SIMPLE_TRANSCENDENTAL_FUNCTION (exp)