Update copyright dates with scripts/update-copyrights.
[glibc.git] / sysdeps / i386 / fpu / e_log10.S
blob17277084ca9858cd4868ca0342b6b64d078ebc02
1 /*
2  * Written by J.T. Conklin <jtc@netbsd.org>.
3  * Public domain.
4  *
5  * Changed to use fyl2xp1 for values near 1, <drepper@cygnus.com>.
6  */
8 #include <machine/asm.h>
10         .section .rodata.cst8,"aM",@progbits,8
12         .p2align 3
13         .type one,@object
14 one:    .double 1.0
15         ASM_SIZE_DIRECTIVE(one)
16         /* It is not important that this constant is precise.  It is only
17            a value which is known to be on the safe side for using the
18            fyl2xp1 instruction.  */
19         .type limit,@object
20 limit:  .double 0.29
21         ASM_SIZE_DIRECTIVE(limit)
24 #ifdef PIC
25 # define MO(op) op##@GOTOFF(%edx)
26 #else
27 # define MO(op) op
28 #endif
30         .text
31 ENTRY(__ieee754_log10)
32         fldlg2                  // log10(2)
33         fldl    4(%esp)         // x : log10(2)
34 #ifdef PIC
35         LOAD_PIC_REG (dx)
36 #endif
37         fxam
38         fnstsw
39         fld     %st             // x : x : log10(2)
40         sahf
41         jc      3f              // in case x is NaN or ±Inf
42 4:      fsubl   MO(one)         // x-1 : x : log10(2)
43         fld     %st             // x-1 : x-1 : x : log10(2)
44         fabs                    // |x-1| : x-1 : x : log10(2)
45         fcompl  MO(limit)       // x-1 : x : log10(2)
46         fnstsw                  // x-1 : x : log10(2)
47         andb    $0x45, %ah
48         jz      2f
49         fxam
50         fnstsw
51         andb    $0x45, %ah
52         cmpb    $0x40, %ah
53         jne     5f
54         fabs                    // log10(1) is +0 in all rounding modes.
55 5:      fstp    %st(1)          // x-1 : log10(2)
56         fyl2xp1                 // log10(x)
57         ret
59 2:      fstp    %st(0)          // x : log10(2)
60         fyl2x                   // log10(x)
61         ret
63 3:      jp      4b              // in case x is ±Inf
64         fstp    %st(1)
65         fstp    %st(1)
66         ret
67 END (__ieee754_log10)
68 strong_alias (__ieee754_log10, __log10_finite)