Bug 17032

Summary: strtod(3) floating exception
Product: Base System Reporter: nobu <nobu>
Component: alphaAssignee: robert
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description nobu 2000-02-28 04:40:01 UTC
strtod(3) make floating exception when smallest value convert.

How-To-Repeat: try following saple:

#include <stdlib.h>
main(){
   double a=strtod("2.2250738585072014e-308", NULL);
   printf("%g\n", a);
}
Comment 1 nobu 2000-02-29 07:27:37 UTC
  I checked my send-pr alpha/17032 problem.

  The problem live in src/lib/libc/stdlib/strtod.c source code.
The source code assume sizeof(long)==4, then bounded value make
to be exception.

  Well, There is need fix to mach. Then I tried import from NetBSD
source code and hacked that. It seem to work.

Based NetBSD-current source as
    $NetBSD: strtod.c,v 1.33 1999/11/26 07:39:45 msaitoh Exp $

and patched for FreeBSD are:
--- /tmp/strtod.c	Tue Feb 29 15:49:07 2000
+++ strtod.c	Tue Feb 29 16:11:36 2000
@@ -108,6 +108,9 @@
 #endif
 #endif
 
+#if defined(__FreeBSD__) && defined(__alpha__)
+#define IEEE_LITTLE_ENDIAN
+#endif
 #ifdef __arm32__
 /*
  * Although the CPU is little endian the FP has different
@@ -142,8 +145,13 @@
 #include "memory.h"
 #endif
 #endif
+#if defined(__FreeBSD__)
+#define mutex_lock(x)
+#define mutex_unlock(x)
+#else
 #include "extern.h"
 #include "reentrant.h"
+#endif
 
 #ifdef MALLOC
 #ifdef KR_headers
@@ -283,8 +291,13 @@
 #define LSB 1
 #define Sign_bit 0x80000000
 #define Log2P 1
+#if defined(__FreeBSD__) && defined(__alpha__)
+#define Tiny0 0x100000
+#define Tiny1 0
+#else  /* !FreeBSD/alpha */
 #define Tiny0 0
 #define Tiny1 1
+#endif /* FreeBSD/alpha */
 #define Quick_max 14
 #define Int_max 14
 #define Infinite(x) (word0(x) == 0x7ff00000) /* sufficient test for here */

---
Nobuhiro Yasutomi  ISAC, Inc.
http://www.isac.co.jp/
Comment 2 robert freebsd_committer freebsd_triage 2002-11-17 16:50:40 UTC
State Changed
From-To: open->patched

A fix was committed to -CURRENT.
Comment 3 Kris Kennaway freebsd_committer freebsd_triage 2003-07-13 00:37:45 UTC
Responsible Changed
From-To: freebsd-alpha->robert

Robert reported that a patch was committed
Comment 4 robert freebsd_committer freebsd_triage 2003-07-13 20:44:07 UTC
State Changed
From-To: patched->closed

Describes the same bug as PR #12623 and #43567, 
further status updates will occur as follow-ups to 
the latter.