aio: Remove support for BROKEN_THREAD_SIGNALS
[glibc.git] / sysdeps / i386 / fpu / e_logl.S
blob53127d704e7a22f5b9dcc11577a8be996534e22e
1 /*
2  * Written by J.T. Conklin <jtc@netbsd.org>.
3  * Public domain.
4  *
5  * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>.
6  */
8 #include <machine/asm.h>
11         .section .rodata.cst8,"aM",@progbits,8
13         .p2align 3
14         .type one,@object
15 one:    .double 1.0
16         ASM_SIZE_DIRECTIVE(one)
17         /* It is not important that this constant is precise.  It is only
18            a value which is known to be on the safe side for using the
19            fyl2xp1 instruction.  */
20         .type limit,@object
21 limit:  .double 0.29
22         ASM_SIZE_DIRECTIVE(limit)
25 #ifdef PIC
26 # define MO(op) op##@GOTOFF(%edx)
27 #else
28 # define MO(op) op
29 #endif
31         .text
32 ENTRY(__ieee754_logl)
33         fldln2                  // log(2)
34         fldt    4(%esp)         // x : log(2)
35         fxam
36         fnstsw
37 #ifdef PIC
38         LOAD_PIC_REG (dx)
39 #endif
40         fld     %st             // x : x : log(2)
41         sahf
42         jc      3f              // in case x is NaN or +-Inf
43         movzwl  4+8(%esp), %eax
44         cmpl    $0xc000, %eax
45         jae     6f              // x <= -2, avoid overflow from -LDBL_MAX - 1.
46 4:      fsubl   MO(one)         // x-1 : x : log(2)
47 6:      fld     %st             // x-1 : x-1 : x : log(2)
48         fabs                    // |x-1| : x-1 : x : log(2)
49         fcompl  MO(limit)       // x-1 : x : log(2)
50         fnstsw                  // x-1 : x : log(2)
51         andb    $0x45, %ah
52         jz      2f
53         fxam
54         fnstsw
55         andb    $0x45, %ah
56         cmpb    $0x40, %ah
57         jne     5f
58         fabs                    // log(1) is +0 in all rounding modes.
59 5:      fstp    %st(1)          // x-1 : log(2)
60         fyl2xp1                 // log(x)
61         ret
63 2:      fstp    %st(0)          // x : log(2)
64         fyl2x                   // log(x)
65         ret
67 3:      jp      4b              // in case x is +-Inf
68         fstp    %st(1)
69         fstp    %st(1)
70         fadd    %st(0)
71         ret
72 END (__ieee754_logl)
74 ENTRY(__logl_finite)
75         fldln2                  // log(2)
76         fldt    4(%esp)         // x : log(2)
77 #ifdef PIC
78         LOAD_PIC_REG (dx)
79 #endif
80         fld     %st             // x : x : log(2)
81         fsubl   MO(one)         // x-1 : x : log(2)
82         fld     %st             // x-1 : x-1 : x : log(2)
83         fabs                    // |x-1| : x-1 : x : log(2)
84         fcompl  MO(limit)       // x-1 : x : log(2)
85         fnstsw                  // x-1 : x : log(2)
86         andb    $0x45, %ah
87         jz      2b
88         fxam
89         fnstsw
90         andb    $0x45, %ah
91         cmpb    $0x40, %ah
92         jne     7f
93         fabs                    // log(1) is +0 in all rounding modes.
94 7:      fstp    %st(1)          // x-1 : log(2)
95         fyl2xp1                 // log(x)
96         ret
97 END(__logl_finite)