Various minor changes to make these compile on AIX5.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6254
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
/* 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);
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;
#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>
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()
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;
}
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;
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........
{
// 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;
}
{
int x;
- printf ("x = %d\n", x==0xDEADBEEF ? 99 : 88);
+ printf ("x = %d\n", x==0xCAFEBABE ? 99 : 88);
return 0;
}
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);
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);
res = PM(&p, 4096, 100); assert(0 == res &&
0 == (long)p % 4096);
res = PM(&p, 4097, 100); assert(EINVAL == res);
+
+# endif
return 0;
}
#include <fcntl.h>
#include <unistd.h>
+#if !defined(MAP_NORESERVE)
+# define MAP_NORESERVE 0
+#endif
+
int main()
{
char **volatile ptrs;
#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
{
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;
// 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)
setcontext(newc);
}
-int init_context(struct ucontext *uc)
+int init_context(mycontext *uc)
{
void *stack;
int ret;
#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>
exit( 0 );
}
+
+#endif /* !defined(_AIX) */
}
}
+#if !defined(_AIX)
static void
test_strchrnul (void)
{
}
}
}
+#endif /* !defined(_AIX) */
+#if !defined(_AIX)
static void
test_rawmemchr (void)
{
}
}
}
+#endif /* !defined(_AIX) */
static void
test_index (void)
}
}
+#if !defined(_AIX)
static void
test_memrchr (void)
{
}
}
}
+#endif /* !defined(_AIX) */
static void
test_rindex (void)
equal(one+4, "c", 50);
{
+# if !defined(_AIX)
char text[] = "This,is,a,test";
char *list = strdupa (text);
equal (strsep (&list, ","), "This", 51);
equal (strsep (&list, ","), "a", 53);
equal (strsep (&list, ","), "test", 54);
check (strsep (&list, ",") == NULL, 55);
+# endif
}
cp = strcpy(one, "a,b, c,, ,d,");
}
}
+#if !defined(_AIX)
static void
test_mempcpy (void)
{
equal (two, "hi there", 12 + (i * 6));
}
}
+#endif /* !defined(_AIX) */
static void
test_memmove (void)
/* strchr. */
test_strchr ();
+# if !defined(_AIX)
/* strchrnul. */
test_strchrnul ();
+# endif
+# if !defined(_AIX)
/* rawmemchr. */
test_rawmemchr ();
+# endif
/* index - just like strchr. */
test_index ();
/* strrchr. */
test_strrchr ();
+# if !defined(_AIX)
/* memrchr. */
test_memrchr ();
+# endif
/* rindex - just like strrchr. */
test_rindex ();
/* memmove - must work on overlap. */
test_memmove ();
+# if !defined(_AIX)
/* mempcpy */
test_mempcpy ();
+# endif
/* memccpy. */
test_memccpy ();
else
{
status = EXIT_FAILURE;
- printf("%Zd errors.\n", errors);
+ printf("%d errors.\n", (int)errors);
}
return status;
#include <stdio.h>
#include <malloc.h>
+#include <stdlib.h>
#include "valgrind.h"
/* As wrap4.c, but also throw in various calls to another redirected
#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.