1/*
2 * Written by J.T. Conklin <jtc@netbsd.org>.
3 * Public domain.
4 */
5
6#include <machine/asm.h>
7
8RCSID("$NetBSD: s_ilogb.S,v 1.5 1995/10/12 15:53:09 jtc Exp $")
9
10ENTRY(__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
22	fxtract
23	pushl	%eax
24	fstp	%st
25
26	fistpl	(%esp)
27	fwait
28	popl	%eax
29
30	ret
31
321:	fstp	%st
33	movl	$0x7fffffff, %eax
34	ret
35END (__ilogb)
36weak_alias (__ilogb, ilogb)
37