This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

math/atest-* fix


The tests math/atest-*.c convert hex strings to multiple-precision numbers 
by using strchr to get a value for the hex digit (as type ptrdiff_t) and 
then shifting appropriately.  This doesn't work if ptrdiff_t is narrower 
than mp_limb_t (as on MIPS64 N32); the value should be cast to mp_limb_t 
before shifting.

2006-06-07  Joseph Myers  <joseph@codesourcery.com>

	* math/atest-exp.c (main): Cast hex value to mp_limb_t before
	shifting.
	* math/atest-exp2.c (read_mpn_hex): Likewise.
	* math/atest-sincos.c (main): Likewise.

Index: math/atest-exp.c
===================================================================
RCS file: /cvs/glibc/libc/math/atest-exp.c,v
retrieving revision 1.7
diff -u -r1.7 atest-exp.c
--- math/atest-exp.c	6 Jul 2001 04:55:35 -0000	1.7
+++ math/atest-exp.c	7 Jun 2006 15:47:47 -0000
@@ -171,7 +171,9 @@
 
    memset (e2, '\0', sizeof (mp1));
    for (i = -1; i < 100 && i < FRAC / 4; i++)
-     e2[(FRAC - i * 4 - 4) / mpbpl] |= ((strchr (hexdig, exp1[i + 1]) - hexdig)
+     e2[(FRAC - i * 4 - 4) / mpbpl] |= ((mp_limb_t) (strchr (hexdig,
+							     exp1[i + 1])
+						     - hexdig)
 					<< (FRAC - i * 4 - 4) % mpbpl);
 
    if (mpn_cmp (ex, e2, SZ) >= 0)
Index: math/atest-exp2.c
===================================================================
RCS file: /cvs/glibc/libc/math/atest-exp2.c,v
retrieving revision 1.8
diff -u -r1.8 atest-exp2.c
--- math/atest-exp2.c	6 Jul 2001 04:55:35 -0000	1.8
+++ math/atest-exp2.c	7 Jun 2006 15:47:48 -0000
@@ -73,7 +73,8 @@
 
   memset (x, 0, sizeof (mp1));
   for (i = -1; i < 100 && i < FRAC / 4; ++i)
-    x[(FRAC - i * 4 - 4) / mpbpl] |= ((strchr (hexdig, str[i + 1]) - hexdig)
+    x[(FRAC - i * 4 - 4) / mpbpl] |= ((mp_limb_t) (strchr (hexdig, str[i + 1])
+						   - hexdig)
 				      << (FRAC - i * 4 - 4) % mpbpl);
 }
 
Index: math/atest-sincos.c
===================================================================
RCS file: /cvs/glibc/libc/math/atest-sincos.c,v
retrieving revision 1.7
diff -u -r1.7 atest-sincos.c
--- math/atest-sincos.c	6 Jul 2001 04:55:35 -0000	1.7
+++ math/atest-sincos.c	7 Jun 2006 15:47:48 -0000
@@ -239,9 +239,11 @@
    memset (c2, 0, sizeof (mp1));
    for (i = 0; i < 100 && i < FRAC / 4; i++)
      {
-       s2[(FRAC - i * 4 - 4) / mpbpl] |= ((strchr (hexdig, sin1[i]) - hexdig)
+       s2[(FRAC - i * 4 - 4) / mpbpl] |= ((mp_limb_t) (strchr (hexdig, sin1[i])
+						       - hexdig)
 					  << (FRAC - i * 4 - 4) % mpbpl);
-       c2[(FRAC - i * 4 - 4) / mpbpl] |= ((strchr (hexdig, cos1[i]) - hexdig)
+       c2[(FRAC - i * 4 - 4) / mpbpl] |= ((mp_limb_t) (strchr (hexdig, cos1[i])
+						       - hexdig)
 					  << (FRAC - i * 4 - 4) % mpbpl);
      }
 

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]