ppc64: Arguments to iselInt128Expr_to_32x4 should be initialized.
[valgrind.git] / memcheck / tests / threadname.c
blobd3f6e44491df9c6cb72e894862ea045780a979de
1 #include "config.h"
3 #define _GNU_SOURCE
4 #include <stdio.h>
5 #include <pthread.h>
6 #include <string.h>
7 #include <stdlib.h>
8 #if defined(HAVE_SYS_PRCTL_H)
9 #include <sys/prctl.h>
10 #endif /* HAVE_SYS_PRCTL_H */
11 #include <sys/types.h>
12 #include <unistd.h>
13 #include <assert.h>
14 #include "valgrind.h"
16 static pthread_t children[3];
18 void bad_things(int offset)
20 char* m = malloc(sizeof(char)*offset);
21 m[offset] = 0;
22 free(m);
25 void* child_fn_2 ( void* arg )
27 const char* threadname = "012345678901234";
29 # if !defined(VGO_darwin)
30 pthread_setname_np(pthread_self(), threadname);
31 # else
32 pthread_setname_np(threadname);
33 # endif
35 bad_things(4);
37 return NULL;
40 void* child_fn_1 ( void* arg )
42 const char* threadname = "try1";
43 int r;
45 # if !defined(VGO_darwin)
46 pthread_setname_np(pthread_self(), threadname);
47 # else
48 pthread_setname_np(threadname);
49 # endif
51 bad_things(3);
52 VALGRIND_PRINTF("%s", "I am in child_fn_1\n");
54 r = pthread_create(&children[2], NULL, child_fn_2, NULL);
55 assert(!r);
57 r = pthread_join(children[2], NULL);
58 assert(!r);
60 return NULL;
63 void* child_fn_0 ( void* arg )
65 int r;
67 bad_things(2);
69 r = pthread_create(&children[1], NULL, child_fn_1, NULL);
70 assert(!r);
72 r = pthread_join(children[1], NULL);
73 assert(!r);
75 return NULL;
78 int main(int argc, const char** argv)
80 int r;
82 bad_things(1);
84 r = pthread_create(&children[0], NULL, child_fn_0, NULL);
85 assert(!r);
87 r = pthread_join(children[0], NULL);
88 assert(!r);
90 bad_things(5);
92 return 0;