2.9
[glibc/nacl-glibc.git] / sysdeps / i386 / fpu / s_ilogbl.S
blob1f559b311ed41361143f5cc20be321cfda615a6f
1 /*
2  * Written by J.T. Conklin <jtc@netbsd.org>.
3  * Changes for long double by Ulrich Drepper <drepper@cygnus.com>
4  * Public domain.
5  */
7 #include <machine/asm.h>
9 RCSID("$NetBSD: $")
11 ENTRY(__ilogbl)
12         fldt    4(%esp)
13 /* I added the following ugly construct because ilogb(+-Inf) is
14    required to return INT_MAX in ISO C99.
15    -- jakub@redhat.com.  */
16         fxam                    /* Is NaN or +-Inf?  */
17         fstsw   %ax
18         movb    $0x45, %dh
19         andb    %ah, %dh
20         cmpb    $0x05, %dh
21         je      1f              /* Is +-Inf, jump.  */
23         fxtract
24         pushl   %eax
25         cfi_adjust_cfa_offset (4)
26         fstp    %st
28         fistpl  (%esp)
29         fwait
30         popl    %eax
31         cfi_adjust_cfa_offset (-4)
33         ret
35 1:      fstp    %st
36         movl    $0x7fffffff, %eax
37         ret
38 END (__ilogbl)
39 weak_alias (__ilogbl, ilogbl)