summaryrefslogtreecommitdiffstats
path: root/lib/msun/i387
diff options
context:
space:
mode:
authorstefanf <stefanf@FreeBSD.org>2004-06-19 09:30:00 +0000
committerstefanf <stefanf@FreeBSD.org>2004-06-19 09:30:00 +0000
commitac3aff330075054b5dd3eb4aaf48991fc3ca1d7c (patch)
treea09537e97cdb74aa234d3df047d2805a4f77daa4 /lib/msun/i387
parent127bbb4fe3f68ad22d400dd4d7dcf14f9104bc81 (diff)
downloadFreeBSD-src-ac3aff330075054b5dd3eb4aaf48991fc3ca1d7c.zip
FreeBSD-src-ac3aff330075054b5dd3eb4aaf48991fc3ca1d7c.tar.gz
Return the same result as the MI version for 0.0, INFINITY and NaN.
Reviewed by: standards@
Diffstat (limited to 'lib/msun/i387')
-rw-r--r--lib/msun/i387/s_ilogb.S32
1 files changed, 31 insertions, 1 deletions
diff --git a/lib/msun/i387/s_ilogb.S b/lib/msun/i387/s_ilogb.S
index c9de0bd..34497a8 100644
--- a/lib/msun/i387/s_ilogb.S
+++ b/lib/msun/i387/s_ilogb.S
@@ -33,10 +33,15 @@
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
*/
+#include <machine/_limits.h>
#include <machine/asm.h>
RCSID("$FreeBSD$")
+#define FP_ILOGB0 (-__INT_MAX)
+#define FP_ILOGBNAN __INT_MAX
+#define FP_ILOGBINF __INT_MAX
+
ENTRY(ilogb)
pushl %ebp
movl %esp,%ebp
@@ -44,10 +49,35 @@ ENTRY(ilogb)
fldl 8(%ebp)
fxtract
- fstp %st
+ fstp %st(0)
fistpl -4(%ebp)
movl -4(%ebp),%eax
+ /* fistpl yields __INT_MIN for NaN, Inf and 0. */
+ cmpl $__INT_MIN,%eax
+ je .L2
+
+.L1:
leave
ret
+
+.L2:
+ fldl 8(%ebp)
+ fldz
+ fucompp
+ fnstsw %ax
+ sahf
+ jp .L3
+ jz .L4
+
+ movl $FP_ILOGBINF,%eax
+ jmp .L1
+
+.L3:
+ movl $FP_ILOGBNAN,%eax
+ jmp .L1
+
+.L4:
+ movl $FP_ILOGB0,%eax
+ jmp .L1
OpenPOWER on IntegriCloud