[Gmp-commit] /home/hgfiles/gmp: 5 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Sat Nov 13 18:27:12 CET 2010


details:   /home/hgfiles/gmp/rev/d895ac2ed56c
changeset: 13686:d895ac2ed56c
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Sat Nov 13 18:16:58 2010 +0100
description:
config.guess (x86): Make test C snippet compatible with C++.

details:   /home/hgfiles/gmp/rev/5d3da0338cd6
changeset: 13687:5d3da0338cd6
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Sat Nov 13 18:20:25 2010 +0100
description:
Make several test code snippets C++ compatible.

details:   /home/hgfiles/gmp/rev/866ba107f4e0
changeset: 13688:866ba107f4e0
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Sat Nov 13 18:22:08 2010 +0100
description:
Add explicit casts for type conversions.

details:   /home/hgfiles/gmp/rev/13d78e028fe3
changeset: 13689:13d78e028fe3
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Sat Nov 13 18:25:23 2010 +0100
description:
Misc cleanup.  Fail with a syntax error for non-IEEE fp formats.

details:   /home/hgfiles/gmp/rev/76a82758f509
changeset: 13690:76a82758f509
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Sat Nov 13 18:27:08 2010 +0100
description:
(__GNU_MP_VERSION_PATCHLEVEL): Bump.

diffstat:

 ChangeLog           |   14 ++
 acinclude.m4        |   25 ++-
 config.guess        |    9 +-
 gmp-h.in            |    2 +-
 mpn/generic/get_d.c |  300 +++++++++------------------------------------------
 tests/devel/try.c   |    4 +-
 6 files changed, 97 insertions(+), 257 deletions(-)

diffs (truncated from 547 to 300 lines):

diff -r e7d283e360c8 -r 76a82758f509 ChangeLog
--- a/ChangeLog	Fri Nov 12 22:06:32 2010 +0100
+++ b/ChangeLog	Sat Nov 13 18:27:08 2010 +0100
@@ -1,3 +1,17 @@
+2010-11-13  Torbjorn Granlund  <tege at gmplib.org>
+
+	* mpn/generic/get_d.c: Misc cleanup.  Fail with a syntax error for
+	non-IEEE fp formats.
+
+	* tests/devel/try.c (malloc_region): Add explicit casts for type
+	conversions.
+
+	* acinclude.m4 (GMP_ASM_RODATA): Make test code snippet C++ compatible.
+	(GMP_C_DOUBLE_FORMAT): Likewise.
+	(GMP_FUNC_VSNPRINTF): Likewise.
+	
+	* config.guess (x86): Make test C snippet C++ compatible.
+
 2010-11-12  Torbjorn Granlund  <tege at gmplib.org>
 
 	* Makefile.am: Remove mpbsd.
diff -r e7d283e360c8 -r 76a82758f509 acinclude.m4
--- a/acinclude.m4	Fri Nov 12 22:06:32 2010 +0100
+++ b/acinclude.m4	Sat Nov 13 18:27:08 2010 +0100
@@ -1941,6 +1941,7 @@
 esac
 
 cat >conftest.c <<EOF
+extern const int foo;		/* Suppresses C++'s suppression of foo */
 const int foo = 123;
 EOF
 echo "Test program:" >&AC_FD_CC
@@ -3092,14 +3093,17 @@
 dnl  Determine the floating point format.
 dnl
 dnl  The object file is grepped, in order to work when cross compiling.  A
-dnl  start and end sequence is included to avoid false matches, and
-dnl  allowance is made for the desired data crossing an "od -b" line
-dnl  boundary.  The test number is a small integer so it should appear
-dnl  exactly, no rounding or truncation etc.
+dnl  start and end sequence is included to avoid false matches, and allowance
+dnl  is made for the desired data crossing an "od -b" line boundary.  The test
+dnl  number is a small integer so it should appear exactly, no rounding or
+dnl  truncation etc.
 dnl
 dnl  "od -b", incidentally, is supported even by Unix V7, and the awk script
 dnl  used doesn't have functions or anything, so even an "old" awk should
 dnl  suffice.
+dnl
+dnl  The C code here declares the variable foo as extern; without that, some
+dnl  C++ compilers will not put foo in the object file.
 
 AC_DEFUN([GMP_C_DOUBLE_FORMAT],
 [AC_REQUIRE([AC_PROG_CC])
@@ -3108,11 +3112,13 @@
                 gmp_cv_c_double_format,
 [gmp_cv_c_double_format=unknown
 cat >conftest.c <<\EOF
-[struct {
+[struct foo {
   char    before[8];
   double  x;
   char    after[8];
-} foo = {
+};
+extern struct foo foo;
+struct foo foo = {
   { '\001', '\043', '\105', '\147', '\211', '\253', '\315', '\357' },
   -123456789.0,
   { '\376', '\334', '\272', '\230', '\166', '\124', '\062', '\020' },
@@ -3522,7 +3528,7 @@
   AC_CACHE_CHECK([whether vsnprintf works],
                  gmp_cv_func_vsnprintf,
   [gmp_cv_func_vsnprintf=yes
-   for i in 'check ("hello world");' 'int n; check ("%nhello world", &n);'; do
+   for i in 'return check ("hello world");' 'int n; return check ("%nhello world", &n);'; do
      AC_TRY_RUN([
 #include <string.h>  /* for strcmp */
 #include <stdio.h>   /* for vsnprintf */
@@ -3556,11 +3562,11 @@
   ret = vsnprintf (buf, 4, fmt, ap);
 
   if (strcmp (buf, "hel") != 0)
-    exit (1);
+    return 1;
 
   /* allowed return values */
   if (ret != -1 && ret != 3 && ret != 11)
-    exit (2);
+    return 2;
 
   return 0;
 }
@@ -3569,7 +3575,6 @@
 main ()
 {
 $i
-  exit (0);
 }
 ],
       [:],
diff -r e7d283e360c8 -r 76a82758f509 config.guess
--- a/config.guess	Fri Nov 12 22:06:32 2010 +0100
+++ b/config.guess	Sat Nov 13 18:27:08 2010 +0100
@@ -704,13 +704,20 @@
 	ret
 EOF
   cat <<EOF >${dummy}2.c
+#include <string.h>
+#include <stdio.h>
+#if __cplusplus
+extern "C"
+#endif
+unsigned int cpuid (char dummy_string[12], int);
+int
 main ()
 {
   char vendor_string[13];
   char dummy_string[12];
   long fms;
   int family, model, stepping;
-  char *modelstr;
+  const char *modelstr;
   int cpu_64bit = 0;
 
   cpuid (vendor_string, 0);
diff -r e7d283e360c8 -r 76a82758f509 gmp-h.in
--- a/gmp-h.in	Fri Nov 12 22:06:32 2010 +0100
+++ b/gmp-h.in	Sat Nov 13 18:27:08 2010 +0100
@@ -2273,7 +2273,7 @@
 /* Major version number is the value of __GNU_MP__ too, above and in mp.h. */
 #define __GNU_MP_VERSION 5
 #define __GNU_MP_VERSION_MINOR 0
-#define __GNU_MP_VERSION_PATCHLEVEL 1
+#define __GNU_MP_VERSION_PATCHLEVEL 90
 #define __GMP_MP_RELEASE (__GNU_MP_VERSION * 10000 + __GNU_MP_VERSION_MINOR * 100 + __GNU_MP_VERSION_PATCHLEVEL)
 
 #define __GMP_H__
diff -r e7d283e360c8 -r 76a82758f509 mpn/generic/get_d.c
--- a/mpn/generic/get_d.c	Fri Nov 12 22:06:32 2010 +0100
+++ b/mpn/generic/get_d.c	Sat Nov 13 18:27:08 2010 +0100
@@ -4,7 +4,7 @@
    CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
    FUTURE GNU MP RELEASES.
 
-Copyright 2003, 2004, 2007, 2009 Free Software Foundation, Inc.
+Copyright 2003, 2004, 2007, 2009, 2010 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -133,6 +133,10 @@
 double
 mpn_get_d (mp_srcptr up, mp_size_t size, mp_size_t sign, long exp)
 {
+  int lshift, nbits;
+  union ieee_double_extract u;
+  mp_limb_t x, mhi, mlo;
+
   ASSERT (size >= 0);
   ASSERT_MPN (up, size);
   ASSERT (size == 0 || up[size-1] != 0);
@@ -157,46 +161,43 @@
       exp += GMP_NUMB_BITS * size;
     }
 
+  up += size;
 
-#if 1
-{
-  int lshift, nbits;
-  union ieee_double_extract u;
-  mp_limb_t x, mhi, mlo;
+#if ! _GMP_IEEE_FLOATS
+you lose
+#endif
+
 #if GMP_LIMB_BITS == 64
-  mp_limb_t m;
-  up += size;
-  m = *--up;
-  count_leading_zeros (lshift, m);
+  mlo = up[-1];
+  count_leading_zeros (lshift, mlo);
 
   exp -= (lshift - GMP_NAIL_BITS) + 1;
-  m <<= lshift;
+  mlo <<= lshift;
 
   nbits = GMP_LIMB_BITS - lshift;
 
   if (nbits < 53 && size > 1)
     {
-      x = *--up;
+      x = up[-2];
       x <<= GMP_NAIL_BITS;
       x >>= nbits;
-      m |= x;
+      mlo |= x;
       nbits += GMP_NUMB_BITS;
 
       if (LIMBS_PER_DOUBLE >= 3 && nbits < 53 && size > 2)
 	{
-	  x = *--up;
+	  x = up[-3];
 	  x <<= GMP_NAIL_BITS;
 	  x >>= nbits;
-	  m |= x;
+	  mlo |= x;
 	  nbits += GMP_NUMB_BITS;
 	}
     }
-  mhi = m >> (32 + 11);
-  mlo = m >> 11;
+  mhi = mlo >> (32 + 11);
+  mlo = mlo >> 11;		/* later implicitly truncated to 32 bits */
 #endif
 #if GMP_LIMB_BITS == 32
-  up += size;
-  x = *--up, size--;
+  x = *--up;
   count_leading_zeros (lshift, x);
 
   exp -= (lshift - GMP_NAIL_BITS) + 1;
@@ -212,7 +213,7 @@
     }
   else
     {
-      if (size != 0)
+      if (size > 1)
 	{
 	  nbits = GMP_LIMB_BITS - lshift;
 
@@ -230,25 +231,27 @@
 	}
     }
 
-  if (LIMBS_PER_DOUBLE >= 2 && nbits < 32 && size != 0)
+  /* Now all needed bits in mhi have been accumulated.  Add bits to mlo.  */
+
+  if (LIMBS_PER_DOUBLE >= 2 && nbits < 32 && size > 1)
     {
-      x = *--up, size--;
+      x = up[-1];
       x <<= GMP_NAIL_BITS;
       x >>= nbits;
       mlo |= x;
       nbits += GMP_NUMB_BITS;
 
-      if (LIMBS_PER_DOUBLE >= 3 && nbits < 32 && size != 0)
+      if (LIMBS_PER_DOUBLE >= 3 && nbits < 32 && size > 2)
 	{
-	  x = *--up, size--;
+	  x = up[-2];
 	  x <<= GMP_NAIL_BITS;
 	  x >>= nbits;
 	  mlo |= x;
 	  nbits += GMP_NUMB_BITS;
 
-	  if (LIMBS_PER_DOUBLE >= 4 && nbits < 32 && size != 0)
+	  if (LIMBS_PER_DOUBLE >= 4 && nbits < 32 && size > 3)
 	    {
-	      x = *--up;
+	      x = up[-3];
 	      x <<= GMP_NAIL_BITS;
 	      x >>= nbits;
 	      mlo |= x;
@@ -260,231 +263,42 @@
  done:;
 
 #endif
-  {
-    if (UNLIKELY (exp >= CONST_1024))
-      {
-	/* overflow, return infinity */
-      ieee_infinity:
-	mhi = 0;
-	mlo = 0;
-	exp = 1024;
-      }
-    else if (UNLIKELY (exp <= CONST_NEG_1023))
-      {
-	int rshift;
+  if (UNLIKELY (exp >= CONST_1024))
+    {
+      /* overflow, return infinity */
+    ieee_infinity:
+      mhi = 0;
+      mlo = 0;
+      exp = 1024;
+    }
+  else if (UNLIKELY (exp <= CONST_NEG_1023))
+    {
+      int rshift;
 
-	if (LIKELY (exp <= CONST_NEG_1022_SUB_53))
-	  return 0.0;	 /* denorm underflows to zero */
+      if (LIKELY (exp <= CONST_NEG_1022_SUB_53))
+	return 0.0;	 /* denorm underflows to zero */
 
-	rshift = -1022 - exp;


More information about the gmp-commit mailing list