Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorDanny Smith <dannysmith@users.sourceforge.net>2004-07-27 12:03:36 +0400
committerDanny Smith <dannysmith@users.sourceforge.net>2004-07-27 12:03:36 +0400
commit5ea3a6e15288bdb3e30f54900640a8fccc15dbc5 (patch)
tree7ed4a1954d338fc905146a86a305c76550d35798 /winsup
parent1856fdbe035dd45981acec19c615284d3860b351 (diff)
* 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.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/mingw/ChangeLog6
-rw-r--r--winsup/mingw/mingwex/math/expl.c34
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 <dannysmith@users.sourceforge.net>
+
+ * 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 <dannysmith@users.sourceforge.net>
* 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 <math.h>
+#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);
+}