2.9
[glibc/nacl-glibc.git] / sysdeps / i386 / fpu / s_ilogb.S
blob0cf1ad7419fada8d28b7eccb4572a741857f8f6e
1 /*
2  * Written by J.T. Conklin <jtc@netbsd.org>.
3  * Public domain.
4  */
6 #include <machine/asm.h>
8 RCSID("$NetBSD: s_ilogb.S,v 1.5 1995/10/12 15:53:09 jtc Exp $")
10 ENTRY(__ilogb)
11         fldl    4(%esp)
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.  */
22         fxtract
23         pushl   %eax
24         cfi_adjust_cfa_offset (4)
25         fstp    %st
27         fistpl  (%esp)
28         fwait
29         popl    %eax
30         cfi_adjust_cfa_offset (-4)
32         ret
34 1:      fstp    %st
35         movl    $0x7fffffff, %eax
36         ret
37 END (__ilogb)
38 weak_alias (__ilogb, ilogb)