cpython: 565f43f6bed4 (original) (raw)

Mercurial > cpython

changeset 69975:565f43f6bed4

Issue #11888: Use system log2() when available I expect the system libc to use more accurate functions than Python. The GNU libc uses for example FYL2X and FYL2XP1 hardware instructions on Intel FPU. [#11888]

Victor Stinner victor.stinner@haypocalc.com
date Mon, 09 May 2011 12:45:41 +0200
parents c6523d6faef4
children 2fdabf0dc8f7
files Modules/mathmodule.c configure configure.in pyconfig.h.in
diffstat 4 files changed, 10 insertions(+), 3 deletions(-)[+] [-] Modules/mathmodule.c 4 configure 2 configure.in 4 pyconfig.h.in 3

line wrap: on

line diff

--- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -602,6 +602,9 @@ m_log2(double x) } if (x > 0.0) { +#ifdef HAVE_LOG2

+#else double m; int e; m = frexp(x, &e); @@ -617,6 +620,7 @@ m_log2(double x) else { return log(m) / log(2.0) + e; } +#endif } else if (x == 0.0) { errno = EDOM;

--- a/configure +++ b/configure @@ -11864,7 +11864,7 @@ if eval test "x$"$as_ac_var"" = x"yes fi done -for ac_func in hypot lgamma log1p round tgamma +for ac_func in hypot lgamma log1p log2 round tgamma do : as_ac_var=$as_echo "ac_cv_func_$ac_func" | $as_tr_sh ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"

--- a/configure.in +++ b/configure.in @@ -2512,7 +2512,7 @@ AC_CHECK_FUNCS(alarm accept4 setitimer g futimens futimes [](#l3.4) gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid [](#l3.5) getpriority getresuid getresgid getpwent getspnam getspent getsid getwd [](#l3.6)

On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of

--- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -476,6 +476,9 @@ /* Define to 1 if you have the log1p' function. */[](#l4.4) #undef HAVE_LOG1P[](#l4.5) [](#l4.6) +/* Define to 1 if you have the log2' function. / +#undef HAVE_LOG2 + / Define this if you have the type long double. */ #undef HAVE_LONG_DOUBLE