[kaffe] DoublePrint fix for 64-bit platforms
Gwenole Beauchesne
gbeauchesne at mandriva.com
Mon Sep 12 08:33:13 PDT 2005
Hi,
Here is a quick fix for DoublePrint test failure on 64-bit platforms. The
fdlibm code is not 64-bit clean, so I temporarily switched all occurrences
of 'long' to 'int' to make them 32-bit, as expected. The better fix is to
find out why ->_maxwds could be 0 and make mprec.c (lshift) going into an
infinite loop.
The GCC part (for gij) is also affected.
No ChangeLog because I'd prefer have the right fix, probably when I sleep
enough. ;-)
Index: libraries/clib/fdlibm/dtoa.c
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/clib/fdlibm/dtoa.c,v
retrieving revision 1.3
diff -u -r1.3 dtoa.c
--- libraries/clib/fdlibm/dtoa.c 31 May 2005 21:18:30 -0000 1.3
+++ libraries/clib/fdlibm/dtoa.c 12 Sep 2005 13:45:33 -0000
@@ -35,12 +35,12 @@
_Jv_Bigint * b _AND _Jv_Bigint * S)
{
int n;
- long borrow, y;
- unsigned long carry, q, ys;
- unsigned long *bx, *bxe, *sx, *sxe;
+ int borrow, y;
+ unsigned int carry, q, ys;
+ unsigned int *bx, *bxe, *sx, *sxe;
#ifdef Pack_32
- long z;
- unsigned long si, zs;
+ int z;
+ unsigned int si, zs;
#endif
n = S->_wds;
@@ -145,7 +145,7 @@
print (_Jv_Bigint * b)
{
int i, wds;
- unsigned long *x, y;
+ unsigned int *x, y;
wds = b->_wds;
x = b->_x+wds;
i = 0;
@@ -249,10 +249,10 @@
k_check, leftright, m2, m5, s2, s5, try_quick;
int ilim = 0, ilim1 = 0, spec_case = 0;
union double_union d, d2, eps;
- long L;
+ int L;
#ifndef Sudden_Underflow
int denorm;
- unsigned long x;
+ unsigned int x;
#endif
_Jv_Bigint *b, *b1, *delta, *mlo = NULL, *mhi, *S;
double ds;
@@ -441,8 +441,8 @@
default:
break;
}
- j = sizeof (unsigned long);
- for (ptr->_result_k = 0; (int) (sizeof (_Jv_Bigint) - sizeof (unsigned long)) + j <= i;
+ j = sizeof (unsigned int);
+ for (ptr->_result_k = 0; (int) (sizeof (_Jv_Bigint) - sizeof (unsigned int)) + j <= i;
j <<= 1)
ptr->_result_k++;
ptr->_result = Balloc (ptr, ptr->_result_k);
Index: libraries/clib/fdlibm/mprec.c
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/clib/fdlibm/mprec.c,v
retrieving revision 1.3
diff -u -r1.3 mprec.c
--- libraries/clib/fdlibm/mprec.c 31 May 2005 21:18:30 -0000 1.3
+++ libraries/clib/fdlibm/mprec.c 12 Sep 2005 13:45:33 -0000
@@ -120,7 +120,7 @@
void
_DEFUN (Bfree, (ptr, v), struct _Jv_reent *ptr _AND _Jv_Bigint * v)
{
- long i;
+ int i;
i = v - ptr->_freelist;
@@ -139,9 +139,9 @@
int a)
{
int i, wds;
- unsigned long *x, y;
+ unsigned int *x, y;
#ifdef Pack_32
- unsigned long xi, z;
+ unsigned int xi, z;
#endif
_Jv_Bigint *b1;
@@ -184,11 +184,11 @@
_CONST char *s _AND
int nd0 _AND
int nd _AND
- unsigned long y9)
+ unsigned int y9)
{
_Jv_Bigint *b;
int i, k;
- long x, y;
+ int x, y;
x = (nd + 8) / 9;
for (k = 0, y = 1; x > y; y <<= 1, k++);
@@ -220,7 +220,7 @@
int
_DEFUN (hi0bits,
- (x), register unsigned long x)
+ (x), register unsigned int x)
{
register int k = 0;
@@ -254,10 +254,10 @@
}
int
-_DEFUN (lo0bits, (y), unsigned long *y)
+_DEFUN (lo0bits, (y), unsigned int *y)
{
register int k;
- register unsigned long x = *y;
+ register unsigned int x = *y;
if (x & 7)
{
@@ -319,10 +319,10 @@
{
_Jv_Bigint *c;
int k, wa, wb, wc;
- unsigned long carry, y, z;
- unsigned long *x, *xa, *xae, *xb, *xbe, *xc, *xc0;
+ unsigned int carry, y, z;
+ unsigned int *x, *xa, *xae, *xb, *xbe, *xc, *xc0;
#ifdef Pack_32
- unsigned long z2;
+ unsigned int z2;
#endif
if (a->_wds < b->_wds)
@@ -450,7 +450,7 @@
{
int i, k1, n, n1;
_Jv_Bigint *b1;
- unsigned long *x, *x1, *xe, z;
+ unsigned int *x, *x1, *xe, z;
#ifdef Pack_32
n = k >> 5;
@@ -508,7 +508,7 @@
int
_DEFUN (cmp, (a, b), _Jv_Bigint * a _AND _Jv_Bigint * b)
{
- unsigned long *xa, *xa0, *xb, *xb0;
+ unsigned int *xa, *xa0, *xb, *xb0;
int i, j;
i = a->_wds;
@@ -541,10 +541,10 @@
{
_Jv_Bigint *c;
int i, wa, wb;
- long borrow, y; /* We need signed shifts here. */
- unsigned long *xa, *xae, *xb, *xbe, *xc;
+ int borrow, y; /* We need signed shifts here. */
+ unsigned int *xa, *xae, *xb, *xbe, *xc;
#ifdef Pack_32
- long z;
+ int z;
#endif
i = cmp (a, b);
@@ -623,7 +623,7 @@
_DEFUN (ulp, (_x), double _x)
{
union double_union x, a;
- register long L;
+ register int L;
x.d = _x;
@@ -669,11 +669,11 @@
_DEFUN (b2d, (a, e),
_Jv_Bigint * a _AND int *e)
{
- unsigned long *xa, *xa0, w, y, z;
+ unsigned int *xa, *xa0, w, y, z;
int k;
union double_union d;
#ifdef VAX
- unsigned long d0, d1;
+ unsigned int d0, d1;
#else
#define d0 word0(d)
#define d1 word1(d)
@@ -754,9 +754,9 @@
union double_union d;
_Jv_Bigint *b;
int de, i, k;
- unsigned long *x, y, z;
+ unsigned int *x, y, z;
#ifdef VAX
- unsigned long d0, d1;
+ unsigned int d0, d1;
d.d = _d;
d0 = word0 (d) >> 16 | word0 (d) << 16;
d1 = word1 (d) >> 16 | word1 (d) << 16;
Index: libraries/clib/fdlibm/mprec.h
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/clib/fdlibm/mprec.h,v
retrieving revision 1.4
diff -u -r1.4 mprec.h
--- libraries/clib/fdlibm/mprec.h 15 Jul 2005 13:43:05 -0000 1.4
+++ libraries/clib/fdlibm/mprec.h 12 Sep 2005 13:45:33 -0000
@@ -261,11 +261,9 @@
*/
#ifndef Pack_32
-#if SIZEOF_VOID_P != 8
#define Pack_32
#endif
#endif
-#endif
#define MAX_BIGNUMS 16
@@ -275,7 +273,7 @@
{
struct _Jv_Bigint *_next;
int _k, _maxwds, _sign, _wds;
- unsigned long _x[MAX_BIGNUM_WDS];
+ unsigned int _x[MAX_BIGNUM_WDS];
};
@@ -349,19 +347,19 @@
_Jv_Bigint * _EXFUN(Balloc,(struct _Jv_reent *p, int k));
void _EXFUN(Bfree,(struct _Jv_reent *p, _Jv_Bigint *v));
_Jv_Bigint * _EXFUN(multadd,(struct _Jv_reent *p, _Jv_Bigint *, int, int));
-_Jv_Bigint * _EXFUN(s2b,(struct _Jv_reent *, const char*, int, int, unsigned long));
+_Jv_Bigint * _EXFUN(s2b,(struct _Jv_reent *, const char*, int, int, unsigned int));
_Jv_Bigint * _EXFUN(i2b,(struct _Jv_reent *,int));
_Jv_Bigint * _EXFUN(mult, (struct _Jv_reent *, _Jv_Bigint *, _Jv_Bigint *));
_Jv_Bigint * _EXFUN(pow5mult, (struct _Jv_reent *, _Jv_Bigint *, int k));
-int _EXFUN(hi0bits,(unsigned long));
-int _EXFUN(lo0bits,(unsigned long *));
+int _EXFUN(hi0bits,(unsigned int));
+int _EXFUN(lo0bits,(unsigned int *));
_Jv_Bigint * _EXFUN(d2b,(struct _Jv_reent *p, double d, int *e, int *bits));
_Jv_Bigint * _EXFUN(lshift,(struct _Jv_reent *p, _Jv_Bigint *b, int k));
_Jv_Bigint * _EXFUN(diff,(struct _Jv_reent *p, _Jv_Bigint *a, _Jv_Bigint *b));
int _EXFUN(cmp,(_Jv_Bigint *a, _Jv_Bigint *b));
double _EXFUN(ratio,(_Jv_Bigint *a, _Jv_Bigint *b));
-#define Bcopy(x,y) memcpy((char *)&x->_sign, (char *)&y->_sign, y->_wds*sizeof(long) + 2*sizeof(int))
+#define Bcopy(x,y) memcpy((char *)&x->_sign, (char *)&y->_sign, y->_wds*sizeof(int) + 2*sizeof(int))
#if defined(_DOUBLE_IS_32BITS) && defined(__v800)
#define n_bigtens 2
Index: libraries/clib/fdlibm/strtod.c
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/clib/fdlibm/strtod.c,v
retrieving revision 1.3
diff -u -r1.3 strtod.c
--- libraries/clib/fdlibm/strtod.c 31 May 2005 21:18:30 -0000 1.3
+++ libraries/clib/fdlibm/strtod.c 12 Sep 2005 13:45:33 -0000
@@ -111,11 +111,11 @@
int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign, e1, esign, i, j,
k, nd, nd0, nf, nz, nz0, sign;
int digits = 0; /* Number of digits found in fraction part. */
- long e;
+ int e;
_CONST char *s, *s0, *s1;
double aadj, aadj1, adj;
- long L;
- unsigned long y, z;
+ int L;
+ unsigned int y, z;
union double_union rv, rv0;
_Jv_Bigint *bb = NULL, *bb1, *bd = NULL, *bd0, *bs = NULL, *delta = NULL;
More information about the kaffe
mailing list