chiark / gitweb /
eglibc (2.11.3-4+deb6u3) squeeze-lts; urgency=medium
[eglibc.git] / sysdeps / x86_64 / fpu / s_ilogbl.S
1 /*
2  * Written by J.T. Conklin <jtc@netbsd.org>.
3  * Changes for long double by Ulrich Drepper <drepper@cygnus.com>
4  * Adapted for x86-64 by Andreas Jaeger <aj@suse.de>.
5  * Public domain.
6  */
7
8 #include <machine/asm.h>
9
10 ENTRY(__ilogbl)
11         fldt    8(%rsp)
12 /* I added the following ugly construct because ilogb(+-Inf) is
13    required to return INT_MAX in ISO C99.
14    -- jakub@redhat.com.  */
15         fxam                    /* Is NaN or +-Inf?  */
16         fstsw   %ax
17         movb    $0x45, %dh
18         andb    %ah, %dh
19         cmpb    $0x05, %dh
20         je      1f              /* Is +-Inf, jump.  */
21
22         fxtract
23         fstp    %st
24
25         fistpl  -4(%rsp)
26         fwait
27         movl    -4(%rsp),%eax
28
29         ret
30
31 1:      fstp    %st
32         movl    $0x7fffffff, %eax
33         ret
34 END (__ilogbl)
35 weak_alias (__ilogbl, ilogbl)