hurd: fix fcntl visibility
[glibc.git] / sysdeps / x86_64 / fpu / e_log2l.S
blob023ec29164cddda9f61d61a6ace6802d4665fb09
1 /*
2  * Written by J.T. Conklin <jtc@netbsd.org>.
3  * Adapted for use as log2 by Ulrich Drepper <drepper@cygnus.com>.
4  * Public domain.
5  *
6  * Changed to use fyl2xp1 for values near 1, <drepper@cygnus.com>.
7  * Adapted for x86-64 by Andreas Jaeger <aj@suse.de>.
8  */
10 #include <machine/asm.h>
12         .section .rodata.cst8,"aM",@progbits,8
14         .p2align 3
15         .type one,@object
16 one:    .double 1.0
17         ASM_SIZE_DIRECTIVE(one)
18         /* It is not important that this constant is precise.  It is only
19            a value which is known to be on the safe side for using the
20            fyl2xp1 instruction.  */
21         .type limit,@object
22 limit:  .double 0.29
23         ASM_SIZE_DIRECTIVE(limit)
26 #ifdef PIC
27 # define MO(op) op##(%rip)
28 #else
29 # define MO(op) op
30 #endif
32         .text
33 ENTRY(__ieee754_log2l)
34         fldl    MO(one)
35         fldt    8(%rsp)         // x : 1
36         fxam
37         fnstsw
38         fld     %st             // x : x : 1
39         testb   $1, %ah
40         jnz     3f              // in case x is NaN or ±Inf
41 4:      fsub    %st(2), %st     // x-1 : x : 1
42         fld     %st             // x-1 : x-1 : x : 1
43         fabs                    // |x-1| : x-1 : x : 1
44         fcompl  MO(limit)       // x-1 : x : 1
45         fnstsw                  // x-1 : x : 1
46         andb    $0x45, %ah
47         jz      2f
48         fxam
49         fnstsw
50         andb    $0x45, %ah
51         cmpb    $0x40, %ah
52         jne     5f
53         fabs                    // log2(1) is +0 in all rounding modes.
54 5:      fstp    %st(1)          // x-1 : 1
55         fyl2xp1                 // log(x)
56         ret
58 2:      fstp    %st(0)          // x : 1
59         fyl2x                   // log(x)
60         ret
62 3:      testb   $4, %ah
63         jnz     4b              // in case x is ±Inf
64         fstp    %st(1)
65         fstp    %st(1)
66         fadd    %st(0)
67         ret
68 END (__ieee754_log2l)
71 ENTRY(__log2l_finite)
72         fldl    MO(one)
73         fldt    8(%rsp)         // x : 1
74         fld     %st             // x : x : 1
75         fsub    %st(2), %st     // x-1 : x : 1
76         fld     %st             // x-1 : x-1 : x : 1
77         fabs                    // |x-1| : x-1 : x : 1
78         fcompl  MO(limit)       // x-1 : x : 1
79         fnstsw                  // x-1 : x : 1
80         andb    $0x45, %ah
81         jz      2b
82         fxam
83         fnstsw
84         andb    $0x45, %ah
85         cmpb    $0x40, %ah
86         jne     6f
87         fabs                    // log2(1) is +0 in all rounding modes.
88 6:      fstp    %st(1)          // x-1 : 1
89         fyl2xp1                 // log(x)
90         ret
91 END (__log2l_finite)