1/*
2 * Public domain.
3 */
4
5#include <machine/asm.h>
6#include <libm-alias-finite.h>
7
8 .section .rodata.cst8,"aM",@progbits,8
9
10 .p2align 3
11 .type one,@object
12one: .double 1.0
13 ASM_SIZE_DIRECTIVE(one)
14 /* It is not important that this constant is precise. It is only
15 a value which is known to be on the safe side for using the
16 fyl2xp1 instruction. */
17 .type limit,@object
18limit: .double 0.29
19 ASM_SIZE_DIRECTIVE(limit)
20
21
22#ifdef PIC
23# define MO(op) op##@GOTOFF(%edx)
24#else
25# define MO(op) op
26#endif
27
28 .text
29ENTRY(__ieee754_log10)
30 fldlg2 // log10(2)
31 fldl 4(%esp) // x : log10(2)
32#ifdef PIC
33 LOAD_PIC_REG (dx)
34#endif
35 fxam
36 fnstsw
37 fld %st // x : x : log10(2)
38 sahf
39 jc 3f // in case x is NaN or ħInf
404: fsubl MO(one) // x-1 : x : log10(2)
41 fld %st // x-1 : x-1 : x : log10(2)
42 fabs // |x-1| : x-1 : x : log10(2)
43 fcompl MO(limit) // x-1 : x : log10(2)
44 fnstsw // x-1 : x : log10(2)
45 andb $0x45, %ah
46 jz 2f
47 fxam
48 fnstsw
49 andb $0x45, %ah
50 cmpb $0x40, %ah
51 jne 5f
52 fabs // log10(1) is +0 in all rounding modes.
535: fstp %st(1) // x-1 : log10(2)
54 fyl2xp1 // log10(x)
55 ret
56
572: fstp %st(0) // x : log10(2)
58 fyl2x // log10(x)
59 ret
60
613: jp 4b // in case x is ħInf
62 fstp %st(1)
63 fstp %st(1)
64 ret
65END (__ieee754_log10)
66libm_alias_finite (__ieee754_log10, __log10)
67

source code of glibc/sysdeps/i386/fpu/e_log10.S