]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/i386/fpu/e_log10l.S
(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[thirdparty/glibc.git] / sysdeps / i386 / fpu / e_log10l.S
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 */
9
10 #include <machine/asm.h>
11
12 RCSID("$NetBSD: $")
13
14 #ifdef __ELF__
15 .section .rodata
16 #else
17 .text
18 #endif
19 .align ALIGNARG(4)
20 ASM_TYPE_DIRECTIVE(one,@object)
21 one: .double 1.0
22 ASM_SIZE_DIRECTIVE(one)
23 /* It is not important that this constant is precise. It is only
24 a value which is known to be on the safe side for using the
25 fyl2xp1 instruction. */
26 ASM_TYPE_DIRECTIVE(limit,@object)
27 limit: .double 0.29
28 ASM_SIZE_DIRECTIVE(limit)
29
30
31 #ifdef PIC
32 #define MO(op) op##@GOTOFF(%edx)
33 #else
34 #define MO(op) op
35 #endif
36
37 .text
38 ENTRY(__ieee754_log10l)
39 fldlg2 // log10(2)
40 fldt 4(%esp) // x : log10(2)
41 #ifdef PIC
42 call 1f
43 1: popl %edx
44 addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %edx
45 #endif
46 fxam
47 fnstsw
48 fld %st // x : x : log10(2)
49 sahf
50 jc 3f // in case x is NaN or ±Inf
51 4: fsubl MO(one) // x-1 : x : log10(2)
52 fld %st // x-1 : x-1 : x : log10(2)
53 fabs // |x-1| : x-1 : x : log10(2)
54 fcompl MO(limit) // x-1 : x : log10(2)
55 fnstsw // x-1 : x : log10(2)
56 andb $0x45, %ah
57 jz 2f
58 fstp %st(1) // x-1 : log10(2)
59 fyl2xp1 // log10(x)
60 ret
61
62 2: fstp %st(0) // x : log10(2)
63 fyl2x // log10(x)
64 ret
65
66 3: jp 4b // in case x is ±Inf
67 fstp %st(1)
68 fstp %st(1)
69 ret
70 END(__ieee754_log10l)