Update copyright dates with scripts/update-copyrights.
[glibc.git] / sysdeps / i386 / fpu / e_ilogb.S
blob29ef2214e64c75fff3682e49eb7ae55d50ea62d1
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(__ieee754_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.  */
21         cmpb    $0x40, %dh
22         je      2f              /* Is +-0, jump.  */
24         fxtract
25         pushl   %eax
26         cfi_adjust_cfa_offset (4)
27         fstp    %st
29         fistpl  (%esp)
30         fwait
31         popl    %eax
32         cfi_adjust_cfa_offset (-4)
34         ret
36 1:      fstp    %st
37         movl    $0x7fffffff, %eax
38         ret
39 2:      fstp    %st
40         movl    $0x80000000, %eax       /* FP_ILOGB0  */
41         ret
42 END (__ieee754_ilogb)