From: Julian Seward Date: Tue, 17 Oct 2006 01:26:12 +0000 (+0000) Subject: Merge r6109: X-Git-Tag: svn/VALGRIND_3_3_0~622 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a48daec904e627b2b0a6dffcf4b7f216f059d269;p=thirdparty%2Fvalgrind.git Merge r6109: Various minor changes to make these compile on AIX5. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6254 --- diff --git a/memcheck/tests/badjump.c b/memcheck/tests/badjump.c index fecb762405..cd9642b8f6 100644 --- a/memcheck/tests/badjump.c +++ b/memcheck/tests/badjump.c @@ -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 diff --git a/memcheck/tests/badjump2.c b/memcheck/tests/badjump2.c index a93c37c82e..d91283cda3 100644 --- a/memcheck/tests/badjump2.c +++ b/memcheck/tests/badjump2.c @@ -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; diff --git a/memcheck/tests/brk.c b/memcheck/tests/brk.c index c578f97d55..0025ed6834 100644 --- a/memcheck/tests/brk.c +++ b/memcheck/tests/brk.c @@ -1,6 +1,8 @@ #include #include -#include +#if !defined(_AIX) +# include +#endif #include #include @@ -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() diff --git a/memcheck/tests/inits.c b/memcheck/tests/inits.c index 7dd0c93c0d..0723f4b566 100644 --- a/memcheck/tests/inits.c +++ b/memcheck/tests/inits.c @@ -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; } diff --git a/memcheck/tests/malloc3.c b/memcheck/tests/malloc3.c index 896645c3eb..21017f48ae 100644 --- a/memcheck/tests/malloc3.c +++ b/memcheck/tests/malloc3.c @@ -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; diff --git a/memcheck/tests/malloc3.stdout.exp b/memcheck/tests/malloc3.stdout.exp index 681c9ece22..d55e585045 100644 --- a/memcheck/tests/malloc3.stdout.exp +++ b/memcheck/tests/malloc3.stdout.exp @@ -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........ diff --git a/memcheck/tests/malloc_usable.c b/memcheck/tests/malloc_usable.c index 670bc98c0f..a42a5a5b32 100644 --- a/memcheck/tests/malloc_usable.c +++ b/memcheck/tests/malloc_usable.c @@ -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; } diff --git a/memcheck/tests/manuel1.c b/memcheck/tests/manuel1.c index ac1f3c89ec..f2030e4b7f 100644 --- a/memcheck/tests/manuel1.c +++ b/memcheck/tests/manuel1.c @@ -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; } diff --git a/memcheck/tests/memalign2.c b/memcheck/tests/memalign2.c index 0da0b4f32a..daddb25494 100644 --- a/memcheck/tests/memalign2.c +++ b/memcheck/tests/memalign2.c @@ -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; } diff --git a/memcheck/tests/pointer-trace.c b/memcheck/tests/pointer-trace.c index b59de87ff6..047dcce4d1 100644 --- a/memcheck/tests/pointer-trace.c +++ b/memcheck/tests/pointer-trace.c @@ -9,6 +9,10 @@ #include #include +#if !defined(MAP_NORESERVE) +# define MAP_NORESERVE 0 +#endif + int main() { char **volatile ptrs; diff --git a/memcheck/tests/sigprocmask.c b/memcheck/tests/sigprocmask.c index dc8fe526cb..d358af4a27 100644 --- a/memcheck/tests/sigprocmask.c +++ b/memcheck/tests/sigprocmask.c @@ -1,7 +1,9 @@ #include #include -#include +#if !defined(_AIX) +# include +#endif #include // 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; diff --git a/memcheck/tests/stack_changes.c b/memcheck/tests/stack_changes.c index 45ac9e3fe1..71b754ae26 100644 --- a/memcheck/tests/stack_changes.c +++ b/memcheck/tests/stack_changes.c @@ -10,10 +10,16 @@ // 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; diff --git a/memcheck/tests/stack_switch.c b/memcheck/tests/stack_switch.c index 290bbb14d7..45cde8e149 100644 --- a/memcheck/tests/stack_switch.c +++ b/memcheck/tests/stack_switch.c @@ -1,8 +1,18 @@ #define _XOPEN_SOURCE 600 #define _BSD_SOURCE -#include #include + +#if defined(_AIX) +int main(int argc, char **argv) +{ + printf("this test is linux-specific\n"); + return 0; +} + +#else + +#include #include #include #include @@ -53,3 +63,5 @@ int main(int argc, char **argv) exit( 0 ); } + +#endif /* !defined(_AIX) */ diff --git a/memcheck/tests/str_tester.c b/memcheck/tests/str_tester.c index 68fb808173..c552f4142f 100644 --- a/memcheck/tests/str_tester.c +++ b/memcheck/tests/str_tester.c @@ -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; diff --git a/memcheck/tests/wrap5.c b/memcheck/tests/wrap5.c index 7f35e4726d..b544571824 100644 --- a/memcheck/tests/wrap5.c +++ b/memcheck/tests/wrap5.c @@ -1,6 +1,7 @@ #include #include +#include #include "valgrind.h" /* As wrap4.c, but also throw in various calls to another redirected diff --git a/memcheck/tests/wrap8.c b/memcheck/tests/wrap8.c index 39a9c3ca8a..c890657ac0 100644 --- a/memcheck/tests/wrap8.c +++ b/memcheck/tests/wrap8.c @@ -1,6 +1,7 @@ #include #include +#include #include "valgrind.h" /* This is the same as wrap5.c, except that the recursion depth is 16.