]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Make a bit less nonsensical on 64-bit platforms.
authorJulian Seward <jseward@acm.org>
Thu, 19 Jan 2006 03:48:47 +0000 (03:48 +0000)
committerJulian Seward <jseward@acm.org>
Thu, 19 Jan 2006 03:48:47 +0000 (03:48 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5556

memcheck/tests/pointer-trace.c

index 89e3cadf311e4fa8e56cb78e1cf5c9b401d5296f..7449bc0f6fb800ef5743788ab1942605f6a80d84 100644 (file)
 
 int main()
 {
-       const int ptrbits = sizeof(void *) * 8;
-       const int stepbits = 14;
-       const int stepsize = (1 << stepbits);
-       const int nptrs = 1 << (ptrbits - stepbits);
-
        char **volatile ptrs;
        int i;
        int fd;
        char *map;
 
+       /* I _think_ the point of this is to fill ptrs with a pointer
+          to every 4th page in the entire address space, hence
+          guaranteeing that at least one of them points into one of
+          the below traps, and so checks that the leak checker
+          doesn't bomb when following them.  That's fine on 32-bit
+          platforms, but hopeless for a 64-bit system.  So the
+          following settings do achieve that on a 32-bit target but
+          merely make a 64-bit target give the same output without
+          properly testing it. */
+        int ptrbits, stepbits, stepsize, nptrs;
+       if (sizeof(void*) == 8) {
+           /* 64-bit machine */
+          ptrbits = 32;   //bogus
+           stepbits = 14+1;  //bogus
+          stepsize = (1 << stepbits);
+          nptrs = 1 << (ptrbits - stepbits);
+       } else {
+           /* 32-bit machine */
+          ptrbits = 32;
+           stepbits = 14;
+          stepsize = (1 << stepbits);
+          nptrs = 1 << (ptrbits - stepbits);
+       }
+
        ptrs = malloc(nptrs * sizeof(char *));
        for(i = 0; i < nptrs; i++)
-               ptrs[i] = (char *)(i << stepbits);
+               ptrs[i] = (char *)((long)i << stepbits);
 
        /* lay some traps */
        map = mmap(0, stepsize * 2, PROT_NONE, MAP_PRIVATE|MAP_NORESERVE|MAP_ANONYMOUS, -1, 0);