1 #define _XOPEN_SOURCE 600
3 /* Legacy feature macro. */
5 /* New feature macro, always define to squash warning about _BSD_SOURCE
7 #define _DEFAULT_SOURCE 1
16 #include "tests/sys_mman.h"
17 #include <sys/syscall.h>
23 #define STACK_SIZE 8192
26 #define CLONE_THREAD 0x00010000 /* Same thread group? */
29 static int thread_main(void *arg
)
33 memset( buffer
, 1, sizeof( buffer
) );
35 sleep(2); /* ppc64-linux hack */
36 return memchr( buffer
, 1, sizeof( buffer
) ) == NULL
;
39 int main(int argc
, char **argv
)
42 int stackid
__attribute__((unused
));
45 /* "2*" is a ppc64-linux hack */
46 if ( ( stack
= mmap( NULL
, 2* STACK_SIZE
, PROT_READ
|PROT_WRITE
, MAP_PRIVATE
|MAP_ANONYMOUS
, -1, 0 ) ) == MAP_FAILED
)
52 stackid
= VALGRIND_STACK_REGISTER( stack
, stack
+ STACK_SIZE
);
54 if ( ( pid
= clone( thread_main
, stack
+ STACK_SIZE
, CLONE_VM
|CLONE_FS
|CLONE_FILES
|CLONE_SIGHAND
|CLONE_THREAD
|SIGCHLD
, NULL
) ) == -1 )