From 5ea3a6e15288bdb3e30f54900640a8fccc15dbc5 Mon Sep 17 00:00:00 2001 From: Danny Smith Date: Tue, 27 Jul 2004 08:03:36 +0000 Subject: [PATCH] * mingwex/math/expl.c (expl): Move body of code to new static function __expl, removing tests for +/-Inf. Extern function expl calls __expl after testing for max, min log thresholds. --- winsup/mingw/ChangeLog | 6 ++++++ winsup/mingw/mingwex/math/expl.c | 34 +++++++++++++------------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/winsup/mingw/ChangeLog b/winsup/mingw/ChangeLog index 2c55a4728..dbdeb0cdb 100644 --- a/winsup/mingw/ChangeLog +++ b/winsup/mingw/ChangeLog @@ -1,3 +1,9 @@ +2004-07-27 Danny Smith + + * mingwex/math/expl.c (expl): Move body of code to new static + function __expl, removing tests for +/-Inf. Extern function + expl calls __expl after testing for max, min log thresholds. + 2004-07-26 Danny Smith * mingwex/stdio/vsscanf.c: Add "edi" to registers-modified field diff --git a/winsup/mingw/mingwex/math/expl.c b/winsup/mingw/mingwex/math/expl.c index 5f8face2c..9731a902b 100644 --- a/winsup/mingw/mingwex/math/expl.c +++ b/winsup/mingw/mingwex/math/expl.c @@ -23,26 +23,16 @@ */ #include +#include "cephes_mconf.h" /* for max and min log thresholds */ static long double c0 = 1.44268798828125L; static long double c1 = 7.05260771340735992468e-6L; -long double -expl (long double x) +static long double +__expl (long double x) { long double res; - -/* I added the following ugly construct because expl(+-Inf) resulted - in NaN. The ugliness results from the bright minds at Intel. - For the i686 the code can be written better. - -- drepper@cygnus.com. */ - asm ("fxam\n\t" /* Is NaN or +-Inf? */ - "fstsw %%ax\n\t" - "movb $0x45, %%dh\n\t" - "andb %%ah, %%dh\n\t" - "cmpb $0x05, %%dh\n\t" - "je 1f\n\t" /* Is +-Inf, jump. */ - "fldl2e\n\t" /* 1 log2(e) */ + asm ("fldl2e\n\t" /* 1 log2(e) */ "fmul %%st(1),%%st\n\t" /* 1 x log2(e) */ "frndint\n\t" /* 1 i */ "fld %%st(1)\n\t" /* 2 x */ @@ -66,12 +56,16 @@ expl (long double x) "fscale\n\t" /* 2 scale factor is st(1); e^x */ "fstp %%st(1)\n\t" /* 1 */ "fstp %%st(1)\n\t" /* 0 */ - "jmp 2f\n\t" - "1:\ttestl $0x200, %%eax\n\t" /* Test sign. */ - "jz 2f\n\t" /* If positive, jump. */ - "fstp %%st\n\t" - "fldz\n\t" /* Set result to 0. */ - "2:\t\n" : "=t" (res) : "0" (x), "m" (c0), "m" (c1) : "ax", "dx"); return res; } + +long double expl (long double x) +{ + if (x > MAXLOGL) + return INFINITY; + else if (x < MINLOGL) + return 0.0L; + else + return __expl (x); +}