OSDN Git Service

* Makefile.shared: New file.
[pf3gnuchains/pf3gnuchains3x.git] / newlib / libm / machine / i386 / f_expf.c
1 /*
2  * ====================================================
3  * Copyright (C) 1998 by Cygnus Solutions. All rights reserved.
4  *
5  * Permission to use, copy, modify, and distribute this
6  * software is freely granted, provided that this notice
7  * is preserved.
8  * ====================================================
9  */
10
11 /*
12 Fast version of exp using Intel float instructions.
13
14    float _f_expf (float x);
15
16 Function computes e ** x.  The following special cases exist:
17    1. if x is 0.0 ==> return 1.0
18    2. if x is infinity ==> return infinity
19    3. if x is -infinity ==> return 0.0
20    4. if x is NaN ==> return x
21 There is no error checking or setting of errno.
22 */
23
24
25 #include <math.h>
26 #include <ieeefp.h>
27 #include "f_math.h"
28
29 float _f_expf (float x)
30 {
31    if (check_finitef(x))
32      {
33        float result;
34        asm ("fldl2e; fmulp; fld %%st; frndint; fsub %%st,%%st(1); fxch;" \
35           "fchs; f2xm1; fld1; faddp; fxch; fld1; fscale; fstp %%st(1); fmulp" :
36           "=t"(result) : "0"(x));
37        return result;
38      }
39    else if (x == -infinityf())
40      return 0.0;
41
42    return x;
43 }
44
45