]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Merge r6109:
authorJulian Seward <jseward@acm.org>
Tue, 17 Oct 2006 01:26:12 +0000 (01:26 +0000)
committerJulian Seward <jseward@acm.org>
Tue, 17 Oct 2006 01:26:12 +0000 (01:26 +0000)
Various minor changes to make these compile on AIX5.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6254

16 files changed:
memcheck/tests/badjump.c
memcheck/tests/badjump2.c
memcheck/tests/brk.c
memcheck/tests/inits.c
memcheck/tests/malloc3.c
memcheck/tests/malloc3.stdout.exp
memcheck/tests/malloc_usable.c
memcheck/tests/manuel1.c
memcheck/tests/memalign2.c
memcheck/tests/pointer-trace.c
memcheck/tests/sigprocmask.c
memcheck/tests/stack_changes.c
memcheck/tests/stack_switch.c
memcheck/tests/str_tester.c
memcheck/tests/wrap5.c
memcheck/tests/wrap8.c

index fecb762405054be26e3f25dbca29f306280bac64..cd9642b8f60626efd6f445ca6b8d64ff1e194052 100644 (file)
@@ -1,7 +1,7 @@
 
 int main ( void )
 {
-#if defined(__powerpc64__)
+#if defined(__powerpc64__) || defined(_AIX)
    /* on ppc64-linux, a function pointer points to a function
       descriptor, not to the function's entry point.  Hence to get
       uniform behaviour on all supported targets - a jump to 0xE000000
index a93c37c82edf5e0396cbf136c7a655c0851d986b..d91283cda35d7558b95f263e47621d4edf70104a 100644 (file)
@@ -24,7 +24,9 @@ int main(void)
    /* Install own SIGSEGV handler */
    sigsegv_new.sa_handler  = SIGSEGV_handler;
    sigsegv_new.sa_flags    = 0;
+#if !defined(_AIX)
    sigsegv_new.sa_restorer = NULL;
+#endif
    res = sigemptyset( &sigsegv_new.sa_mask );
    assert(res == 0);
 
@@ -33,8 +35,8 @@ int main(void)
 
    if (__builtin_setjmp(myjmpbuf) == 0) {
       // Jump to zero; will cause seg fault
-#if defined(__powerpc64__)
-      unsigned long long int fake_fndescr[3];
+#if defined(__powerpc64__) || defined(_AIX)
+      unsigned long int fake_fndescr[3];
       fake_fndescr[0] = 0;
       fake_fndescr[1] = 0;
       fake_fndescr[2] = 0;
index c578f97d556421a2799c6db78ef5dfd88a2d0770..0025ed68342e1333cb09d1beca34032c77d4efc7 100644 (file)
@@ -1,6 +1,8 @@
 #include <assert.h>
 #include <stdio.h>
-#include <sys/syscall.h>
+#if !defined(_AIX)
+# include <sys/syscall.h>
+#endif
 #include <sys/types.h>
 #include <unistd.h>
 
@@ -27,7 +29,9 @@ int main(void)
    vals[8] = EOL;
 
    for (i = 0; EOL != vals[i]; i++) {
+#     if !defined(_AIX)
       res = (void*)syscall(__NR_brk, vals[i]);
+#     endif
    }
 
    assert( 0 == brk(orig_ds) );  // libc brk()
index 7dd0c93c0d65bb2145f63dc28c16a7820ce4a8cc..0723f4b5664f1f789834ff325072ae9f9ee6c2f0 100644 (file)
@@ -11,10 +11,10 @@ int main(void)
    int        l;
    static int ls;
    
-   if (gs == 0xDEADBEEF) printf("1!\n");
-   if (g  == 0xDEADBEEF) printf("2!\n");
-   if (ls == 0xDEADBEEF) printf("3!\n");
-   if (l  == 0xDEADBEEF) printf("4!\n");  // complains
+   if (gs == 0xCAFEBABE) printf("1!\n");
+   if (g  == 0xCAFEBABE) printf("2!\n");
+   if (ls == 0xCAFEBABE) printf("3!\n");
+   if (l  == 0xCAFEBABE) printf("4!\n");  // complains
    
    return 0;
 }
index 896645c3ebfdb144adbc8a4a6cfe30b945b87b7f..21017f48ae65fd3b2ca6cfcb10d3b4eaa38ec63c 100644 (file)
@@ -9,23 +9,23 @@ int main ( void )
   char* p;
 
   p = malloc(0);
-  printf("malloc(0) = %p\n", p);
+  printf("malloc(0) = 0x%lx\n", (unsigned long)p);
   free(p);
 
   p = malloc(-1);
-  printf("malloc(-1) = %p\n", p);
+  printf("malloc(-1) = 0x%lx\n", (unsigned long)p);
   free(p);
 
   p = calloc(0,1);
-  printf("calloc(0,1) = %p\n", p);
+  printf("calloc(0,1) = 0x%lx\n", (unsigned long)p);
   free(p);
 
   p = calloc(0,-1);
-  printf("calloc(0,-1) = %p\n", p);
+  printf("calloc(0,-1) = 0x%lx\n", (unsigned long)p);
   free(p);
 
   p = calloc(-1,-1);
-  printf("calloc(-1,-1) = %p\n", p);
+  printf("calloc(-1,-1) = 0x%lx\n", (unsigned long)p);
   free(p);
 
   return 0;
index 681c9ece22b0ee0a7e09dbb8266ce4c73dca0b56..d55e585045321ff975088f291b4001644c83e0dd 100644 (file)
@@ -1,5 +1,5 @@
 malloc(0) = 0x........
-malloc(-1) = (nil)
+malloc(-1) = 0x........
 calloc(0,1) = 0x........
-calloc(0,-1) = (nil)
-calloc(-1,-1) = (nil)
+calloc(0,-1) = 0x........
+calloc(-1,-1) = 0x........
index 670bc98c0f1c43d1708102ba7aadd24397a9ff24..a42a5a5b32c4a4d8fd7f4128df7b82f3c9eccdeb 100644 (file)
@@ -7,6 +7,8 @@ int main(void)
 {
    // Since our allocations are in multiples of 8, 99 will round up to 104.
    int* x = malloc(99);
+#  if !defined(_AIX)
    assert(104 == malloc_usable_size(x));
+#  endif
    return 0;
 }
index ac1f3c89ec1632cf9cce3580246cdba0bea318ff..f2030e4b7fe636dc4459344bd272a415e82ad342 100644 (file)
@@ -4,7 +4,7 @@ int main ()
 {
   int x;
 
-  printf ("x = %d\n", x==0xDEADBEEF ? 99 : 88);
+  printf ("x = %d\n", x==0xCAFEBABE ? 99 : 88);
 
   return 0;
 }
index 0da0b4f32a38850a75a3d1c5926a4d077dd1dd31..daddb25494cfbffc3e24899a2dddbad1bb9e8b2f 100644 (file)
@@ -25,7 +25,11 @@ int main ( void )
    int* p;
    int  res;
    assert(sizeof(long int) == sizeof(void*));
-  
+
+#  if defined(_AIX)
+   printf("AIX 5.2 knows about neither memalign() nor posix_memalign().\n");
+
+#  else
    p = memalign(0, 100);      assert(0 == (long)p % 8);
    p = memalign(1, 100);      assert(0 == (long)p % 8);
    p = memalign(2, 100);      assert(0 == (long)p % 8);
@@ -45,7 +49,7 @@ int main ( void )
    p = memalign(4096, 100);   assert(0 == (long)p % 4096);
    p = memalign(4097, 100);   assert(0 == (long)p % 8192);
 
-   #define PM(a,b,c) posix_memalign((void**)a, b, c)
+#  define PM(a,b,c) posix_memalign((void**)a, b, c)
 
    res = PM(&p, -1,100);      assert(EINVAL == res);
    res = PM(&p, 0, 100);      assert(0 == res && 0 == (long)p % 8);
@@ -64,6 +68,8 @@ int main ( void )
    res = PM(&p, 4096, 100);   assert(0 == res &&
                                                  0 == (long)p % 4096); 
    res = PM(&p, 4097, 100);   assert(EINVAL == res);
+
+#  endif
    
    return 0;
 }
index b59de87ff6d82b8c32cb8b946a37e02b770c29cb..047dcce4d172657254f8955b7979d2f4ef17805a 100644 (file)
@@ -9,6 +9,10 @@
 #include <fcntl.h>
 #include <unistd.h>
 
+#if !defined(MAP_NORESERVE)
+#  define MAP_NORESERVE 0
+#endif
+
 int main()
 {
        char **volatile ptrs;
index dc8fe526cb00e4d917e373645263583311fc4ade..d358af4a27e54d9682a5691647fb0ddfdbbf7400 100644 (file)
@@ -1,7 +1,9 @@
 
 #include <signal.h>
 #include <stdio.h>
-#include <sys/syscall.h>
+#if !defined(_AIX)
+# include <sys/syscall.h>
+#endif
 #include <unistd.h>
 
 // Reg test for bug #93328: we were using too-big sigset types, and thus
@@ -11,7 +13,7 @@ int main(void)
 {
    int x[6], *s, *os, i;
 
-#if defined(__NR_sigprocmask) && !defined(__powerpc64__)
+#if defined(__NR_sigprocmask) && !defined(__powerpc64__) && !defined(_AIX)
 
    x[0] = 0x11111111;
    x[1] = 0x89abcdef;
index 45ac9e3fe1ec857b048e6f0dfdae605b7d9b1e37..71b754ae26f3afe2ebd189a5896c2b8cfd962e30 100644 (file)
 // This test is checking the libc context calls (setcontext, etc.) and
 // checks that Valgrind notices their stack changes properly.
 
-struct ucontext ctx1, ctx2, oldc;
+#if defined(_AIX)
+typedef  ucontext_t  mycontext;
+#else /* linux */
+typedef  struct ucontext  mycontext;
+#endif
+
+mycontext ctx1, ctx2, oldc;
 int count;
 
-void hello(struct ucontext *newc)
+void hello(mycontext *newc)
 {
     printf("hello, world: %d\n", count);
     if (count++ == 2)
@@ -21,7 +27,7 @@ void hello(struct ucontext *newc)
     setcontext(newc);
 }
 
-int init_context(struct ucontext *uc)
+int init_context(mycontext *uc)
 {
     void *stack;
     int ret;
index 290bbb14d79be680ab3addb77030bb490607bbb4..45cde8e149ea03c9d8b80b686a40f606c805172d 100644 (file)
@@ -1,8 +1,18 @@
 #define _XOPEN_SOURCE 600
 #define _BSD_SOURCE
 
-#include <sched.h>
 #include <stdio.h>
+
+#if defined(_AIX)
+int main(int argc, char **argv) 
+{
+  printf("this test is linux-specific\n");
+  return 0;
+}
+
+#else
+
+#include <sched.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/mman.h>
@@ -53,3 +63,5 @@ int main(int argc, char **argv)
 
    exit( 0 );
 }
+
+#endif /* !defined(_AIX) */
index 68fb8081737a98f310901057e0fe29c2c8858443..c552f4142f01de2f3eb3d2da0ad0f7880cb449be 100644 (file)
@@ -463,6 +463,7 @@ test_strchr (void)
    }
 }
 
+#if !defined(_AIX)
 static void
 test_strchrnul (void)
 {
@@ -496,7 +497,9 @@ test_strchrnul (void)
       }
    }
 }
+#endif /* !defined(_AIX) */
 
+#if !defined(_AIX)
 static void
 test_rawmemchr (void)
 {
@@ -523,6 +526,7 @@ test_rawmemchr (void)
       }
    }
 }
+#endif /* !defined(_AIX) */
 
 static void
 test_index (void)
@@ -570,6 +574,7 @@ test_strrchr (void)
    }
 }
 
+#if !defined(_AIX)
 static void
 test_memrchr (void)
 {
@@ -615,6 +620,7 @@ test_memrchr (void)
     }
   }
 }
+#endif /* !defined(_AIX) */
 
 static void
 test_rindex (void)
@@ -890,6 +896,7 @@ test_strsep (void)
   equal(one+4, "c", 50);
 
   {
+#   if !defined(_AIX)
     char text[] = "This,is,a,test";
     char *list = strdupa (text);
     equal (strsep (&list, ","), "This", 51);
@@ -897,6 +904,7 @@ test_strsep (void)
     equal (strsep (&list, ","), "a", 53);
     equal (strsep (&list, ","), "test", 54);
     check (strsep (&list, ",") == NULL, 55);
+#   endif
   }
 
   cp = strcpy(one, "a,b, c,, ,d,");
@@ -1049,6 +1057,7 @@ test_memcpy (void)
     }
 }
 
+#if !defined(_AIX)
 static void
 test_mempcpy (void)
 {
@@ -1085,6 +1094,7 @@ test_mempcpy (void)
       equal (two, "hi there", 12 + (i * 6));
     }
 }
+#endif /* !defined(_AIX) */
 
 static void
 test_memmove (void)
@@ -1390,11 +1400,15 @@ main (void)
   /* strchr.  */
   test_strchr ();
 
+# if !defined(_AIX)
   /* strchrnul.  */
   test_strchrnul ();
+# endif
 
+# if !defined(_AIX)
   /* rawmemchr.  */
   test_rawmemchr ();
+# endif
 
   /* index - just like strchr.  */
   test_index ();
@@ -1402,8 +1416,10 @@ main (void)
   /* strrchr.  */
   test_strrchr ();
 
+# if !defined(_AIX)
   /* memrchr.  */
   test_memrchr ();
+# endif
 
   /* rindex - just like strrchr.  */
   test_rindex ();
@@ -1441,8 +1457,10 @@ main (void)
   /* memmove - must work on overlap.  */
   test_memmove ();
 
+# if !defined(_AIX)
   /* mempcpy */
   test_mempcpy ();
+# endif
 
   /* memccpy.  */
   test_memccpy ();
@@ -1479,7 +1497,7 @@ main (void)
   else
     {
       status = EXIT_FAILURE;
-      printf("%Zd errors.\n", errors);
+      printf("%d errors.\n", (int)errors);
     }
 
   return status;
index 7f35e4726d288d133ef2353f1566ed163e387744..b544571824a243eeef7fdd5e672ca78c76db3bdc 100644 (file)
@@ -1,6 +1,7 @@
 
 #include <stdio.h>
 #include <malloc.h>
+#include <stdlib.h>
 #include "valgrind.h"
 
 /* As wrap4.c, but also throw in various calls to another redirected
index 39a9c3ca8ab6e5a89357d83c9d1d3a1f32586906..c890657ac0ee807907d6e13d5fb5af34d5b22d97 100644 (file)
@@ -1,6 +1,7 @@
 
 #include <stdio.h>
 #include <malloc.h>
+#include <stdlib.h>
 #include "valgrind.h"
 
 /* This is the same as wrap5.c, except that the recursion depth is 16.