about summary refs log tree commit diff
path: root/sysdeps/i386/fpu/s_ilogbl.S
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/i386/fpu/s_ilogbl.S')
-rw-r--r--sysdeps/i386/fpu/s_ilogbl.S14
1 files changed, 14 insertions, 0 deletions
diff --git a/sysdeps/i386/fpu/s_ilogbl.S b/sysdeps/i386/fpu/s_ilogbl.S
index 1dad93abeb..ed547bdc8b 100644
--- a/sysdeps/i386/fpu/s_ilogbl.S
+++ b/sysdeps/i386/fpu/s_ilogbl.S
@@ -10,6 +10,16 @@ RCSID("$NetBSD: $")
 
 ENTRY(__ilogbl)
 	fldt	4(%esp)
+/* I added the following ugly construct because ilogb(+-Inf) is
+   required to return INT_MAX in ISO C99.
+   -- jakub@redhat.com.  */
+	fxam			/* Is NaN or +-Inf?  */
+	fstsw   %ax
+	movb    $0x45, %dh
+	andb    %ah, %dh
+	cmpb    $0x05, %dh
+	je      1f		/* Is +-Inf, jump.  */
+
 	fxtract
 	pushl	%eax
 	fstp	%st
@@ -19,5 +29,9 @@ ENTRY(__ilogbl)
 	popl	%eax
 
 	ret
+
+1:	fstp	%st
+	movl	$0x7fffffff, %eax
+	ret
 END (__ilogbl)
 weak_alias (__ilogbl, ilogbl)