Simplify strncat.
[glibc.git] / sysdeps / i386 / fpu / e_log10l.S
blob45b9c6d21d02d03728f326420225502b2ab456e2
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  *
7  * Changed to use fyl2xp1 for values near 1, <drepper@cygnus.com>.
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##@GOTOFF(%edx)
28 #else
29 # define MO(op) op
30 #endif
32         .text
33 ENTRY(__ieee754_log10l)
34         fldlg2                  // log10(2)
35         fldt    4(%esp)         // x : log10(2)
36 #ifdef PIC
37         LOAD_PIC_REG (dx)
38 #endif
39         fxam
40         fnstsw
41         fld     %st             // x : x : log10(2)
42         sahf
43         jc      3f              // in case x is NaN or ±Inf
44 4:      fsubl   MO(one)         // x-1 : x : log10(2)
45         fld     %st             // x-1 : x-1 : x : log10(2)
46         fabs                    // |x-1| : x-1 : x : log10(2)
47         fcompl  MO(limit)       // x-1 : x : log10(2)
48         fnstsw                  // x-1 : x : log10(2)
49         andb    $0x45, %ah
50         jz      2f
51         fxam
52         fnstsw
53         andb    $0x45, %ah
54         cmpb    $0x40, %ah
55         jne     5f
56         fabs                    // log10(1) is +0 in all rounding modes.
57 5:      fstp    %st(1)          // x-1 : log10(2)
58         fyl2xp1                 // log10(x)
59         ret
61 2:      fstp    %st(0)          // x : log10(2)
62         fyl2x                   // log10(x)
63         ret
65 3:      jp      4b              // in case x is ±Inf
66         fstp    %st(1)
67         fstp    %st(1)
68         ret
69 END(__ieee754_log10l)
70 strong_alias (__ieee754_log10l, __log10l_finite)