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
10ENTRY(__ieee754_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 cmpb $0x40, %dh
22 je 2f /* Is +-Inf, jump. */
23
24 fxtract
25 fstp %st
26
27 fistpl -4(%rsp)
28 fwait
29 movl -4(%rsp),%eax
30
31 ret
32
331: fstp %st
34 movl $0x7fffffff, %eax
35 ret
362: fstp %st
37 movl $0x80000000, %eax /* FP_ILOGB0 */
38 ret
39END (__ieee754_ilogbl)
40