Update copyright dates with scripts/update-copyrights.
[glibc.git] / sysdeps / i386 / fpu / e_log10f.S
blob72a3b882518dcc48aa90d0d8f8dc92d3f90434d9
1 /*
2  * Written by J.T. Conklin <jtc@netbsd.org>.
3  * Public domain.
4  * Adapted for float type by Ulrich Drepper <drepper@cygnus.com>.
5  *
6  * Changed to use fyl2xp1 for values near 1, <drepper@cygnus.com>.
7  */
9 #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_log10f)
33         fldlg2                  // log10(2)
34         flds    4(%esp)         // x : log10(2)
35 #ifdef PIC
36         LOAD_PIC_REG (dx)
37 #endif
38         fxam
39         fnstsw
40         fld     %st             // x : x : log10(2)
41         sahf
42         jc      3f              // in case x is NaN or ±Inf
43 4:      fsubl   MO(one)         // x-1 : x : log10(2)
44         fld     %st             // x-1 : x-1 : x : log10(2)
45         fabs                    // |x-1| : x-1 : x : log10(2)
46         fcompl  MO(limit)       // x-1 : x : log10(2)
47         fnstsw                  // x-1 : x : log10(2)
48         andb    $0x45, %ah
49         jz      2f
50         fxam
51         fnstsw
52         andb    $0x45, %ah
53         cmpb    $0x40, %ah
54         jne     5f
55         fabs                    // log10(1) is +0 in all rounding modes.
56 5:      fstp    %st(1)          // x-1 : log10(2)
57         fyl2xp1                 // log10(x)
58         ret
60 2:      fstp    %st(0)          // x : log10(2)
61         fyl2x                   // log10(x)
62         ret
64 3:      jp      4b              // in case x is ±Inf
65         fstp    %st(1)
66         fstp    %st(1)
67         ret
68 END (__ieee754_log10f)
69 strong_alias (__ieee754_log10f, __log10f_finite)