[Gmp-commit] /var/hg/gmp: 2 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Sun Jan 20 00:53:24 CET 2013


details:   /var/hg/gmp/rev/4b2df4c5475e
changeset: 15319:4b2df4c5475e
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Sun Jan 20 00:53:02 2013 +0100
description:
(PTRLIMB): New macro, used for conformant casting.

details:   /var/hg/gmp/rev/af30d0d6a6d9
changeset: 15320:af30d0d6a6d9
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Sun Jan 20 00:53:20 2013 +0100
description:
ChangeLog

diffstat:

 ChangeLog      |   4 ++++
 tests/memory.c |  24 +++++++++++++++---------
 2 files changed, 19 insertions(+), 9 deletions(-)

diffs (87 lines):

diff -r c0fe7a57fa7d -r af30d0d6a6d9 ChangeLog
--- a/ChangeLog	Sat Jan 19 18:35:42 2013 +0100
+++ b/ChangeLog	Sun Jan 20 00:53:20 2013 +0100
@@ -1,3 +1,7 @@
+2013-01-20  Torbjorn Granlund  <tege at gmplib.org>
+
+	* tests/memory.c (PTRLIMB): New macro, used for conformant casting.
+
 2013-01-19 Marco Bodrato <bodrato at mail.dm.unipi.it>
 
 	* mini-gmp/tests/t-double.c (testmain): Get the current free
diff -r c0fe7a57fa7d -r af30d0d6a6d9 tests/memory.c
--- a/tests/memory.c	Sat Jan 19 18:35:42 2013 +0100
+++ b/tests/memory.c	Sun Jan 20 00:53:20 2013 +0100
@@ -1,6 +1,6 @@
 /* Memory allocation used during tests.
 
-Copyright 2001, 2002, 2007 Free Software Foundation, Inc.
+Copyright 2001, 2002, 2007, 2013 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library test suite.
 
@@ -32,6 +32,12 @@
 #define PATTERN2 CNST_LIMB(0xdeadbeef)
 #endif
 
+#if HAVE_INTPTR_T
+#define PTRLIMB(p)  ((mp_limb_t) (intptr_t) p)
+#else
+#define PTRLIMB(p)  ((mp_limb_t) (size_t) p)
+#endif
+
 /* Each block allocated is a separate malloc, for the benefit of a redzoning
    malloc debugger during development or when bug hunting.
 
@@ -92,8 +98,8 @@
   ptr = (void *) ((gmp_intptr_t) rptr + sizeof (mp_limb_t));
 
   *((mp_limb_t *) ((gmp_intptr_t) ptr - sizeof (mp_limb_t)))
-    = PATTERN1 - ((mp_limb_t) ptr);
-  PATTERN2_var = PATTERN2 - ((mp_limb_t) ptr);
+    = PATTERN1 - PTRLIMB (ptr);
+  PATTERN2_var = PATTERN2 - PTRLIMB (ptr);
   memcpy ((void *) ((gmp_intptr_t) ptr + size), &PATTERN2_var, sizeof (mp_limb_t));
 
   h->size = size;
@@ -132,12 +138,12 @@
     }
 
   if (*((mp_limb_t *) ((gmp_intptr_t) ptr - sizeof (mp_limb_t)))
-      != PATTERN1 - ((mp_limb_t) ptr))
+      != PATTERN1 - PTRLIMB (ptr))
     {
       fprintf (stderr, "in realloc: redzone clobbered before block\n");
       abort ();
     }
-  PATTERN2_var = PATTERN2 - ((mp_limb_t) ptr);
+  PATTERN2_var = PATTERN2 - PTRLIMB (ptr);
   if (memcmp ((void *) ((gmp_intptr_t) ptr + h->size), &PATTERN2_var, sizeof (mp_limb_t)))
     {
       fprintf (stderr, "in realloc: redzone clobbered after block\n");
@@ -150,8 +156,8 @@
   ptr = (void *) ((gmp_intptr_t) rptr + sizeof (mp_limb_t));
 
   *((mp_limb_t *) ((gmp_intptr_t) ptr - sizeof (mp_limb_t)))
-    = PATTERN1 - ((mp_limb_t) ptr);
-  PATTERN2_var = PATTERN2 - ((mp_limb_t) ptr);
+    = PATTERN1 - PTRLIMB (ptr);
+  PATTERN2_var = PATTERN2 - PTRLIMB (ptr);
   memcpy ((void *) ((gmp_intptr_t) ptr + new_size), &PATTERN2_var, sizeof (mp_limb_t));
 
   h->size = new_size;
@@ -182,12 +188,12 @@
   *hp = h->next;  /* unlink */
 
   if (*((mp_limb_t *) ((gmp_intptr_t) ptr - sizeof (mp_limb_t)))
-      != PATTERN1 - ((mp_limb_t) ptr))
+      != PATTERN1 - PTRLIMB (ptr))
     {
       fprintf (stderr, "in free: redzone clobbered before block\n");
       abort ();
     }
-  PATTERN2_var = PATTERN2 - ((mp_limb_t) ptr);
+  PATTERN2_var = PATTERN2 - PTRLIMB (ptr);
   if (memcmp ((void *) ((gmp_intptr_t) ptr + h->size), &PATTERN2_var, sizeof (mp_limb_t)))
     {
       fprintf (stderr, "in free: redzone clobbered after block\n");


More information about the gmp-commit mailing list