]>
git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.threads/pthreads.c
4 /* Under OSF 2.0 & 3.0 and HPUX 10, the second arg of pthread_create
5 is prototyped to be just a "pthread_attr_t", while under Solaris it
6 is a "pthread_attr_t *". Arg! */
8 #if defined (__osf__) || defined (__hpux__)
9 #define PTHREAD_CREATE_ARG2(arg) arg
10 #define PTHREAD_CREATE_NULL_ARG2 null_attr
11 static pthread_attr_t null_attr
;
13 #define PTHREAD_CREATE_ARG2(arg) &arg
14 #define PTHREAD_CREATE_NULL_ARG2 NULL
17 static int verbose
= 0;
23 static int from_thread1
;
24 static int from_thread2
;
27 static int full_coverage
;
29 if (verbose
) printf("common_routine (%d)\n", arg
);
43 if (from_main
&& from_thread1
&& from_thread2
)
53 if (verbose
) printf ("thread1 (%0x) ; pid = %d\n", arg
, getpid ());
54 for (i
=1; i
<= 10000000; i
++)
56 if (verbose
) printf("thread1 %d\n", pthread_self ());
70 if (verbose
) printf ("thread2 (%0x) ; pid = %d\n", arg
, getpid ());
71 for (i
=1; i
<= 10000000; i
++)
73 if (verbose
) printf("thread2 %d\n", pthread_self ());
88 if (verbose
) printf("a=%d\n", a
);
101 if (verbose
) printf ("pid = %d\n", getpid());
106 if (pthread_attr_init (&attr
))
108 perror ("pthread_attr_init 1");
113 #ifdef PTHREAD_SCOPE_SYSTEM
114 if (pthread_attr_setscope (&attr
, PTHREAD_SCOPE_SYSTEM
))
116 perror ("pthread_attr_setscope 1");
121 if (pthread_create (&tid1
, PTHREAD_CREATE_ARG2(attr
), thread1
, (void *) 0xfeedface))
123 perror ("pthread_create 1");
126 if (verbose
) printf ("Made thread %d\n", tid1
);
129 if (pthread_create (&tid2
, PTHREAD_CREATE_NULL_ARG2
, thread2
, (void *) 0xdeadbeef))
131 perror ("pthread_create 2");
134 if (verbose
) printf("Made thread %d\n", tid2
);
138 for (j
= 1; j
<= 10000000; j
++)
140 if (verbose
) printf("top %d\n", pthread_self ());