]>
git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.hp/gdb.threads-hp/usrthcore.c
3 /* #include "config.h" */
10 /* Don't even try to compile. In fact, cause a syntax error that we can
11 look for as a compiler error message and know that we have no pthread
12 support. In that case we can just suppress the test completely. */
14 #error "no posix threads support"
18 /* OK. We have the right header. If we try to compile this and fail, then
19 there is something wrong and the user should know about it so the testsuite
20 should issue an ERROR result.. */
23 #define _MIT_POSIX_THREADS 1 /* Linux (or at least RedHat 4.0) needs this */
28 /* Under OSF 2.0 & 3.0 and HPUX 10, the second arg of pthread_create
29 is prototyped to be just a "pthread_attr_t", while under Solaris it
30 is a "pthread_attr_t *". Arg! */
32 #if defined (__osf__) || defined (__hpux__)
33 #define PTHREAD_CREATE_ARG2(arg) arg
34 #define PTHREAD_CREATE_NULL_ARG2 null_attr
35 static pthread_attr_t null_attr
;
37 #define PTHREAD_CREATE_ARG2(arg) &arg
38 #define PTHREAD_CREATE_NULL_ARG2 NULL
41 static int verbose
= 0;
47 static int from_thread1
;
48 static int from_thread2
;
51 static int full_coverage
;
53 if (verbose
) printf("common_routine (%d)\n", arg
);
67 if (from_main
&& from_thread1
&& from_thread2
)
77 if (verbose
) printf ("thread1 (%0x) ; pid = %d\n", arg
, getpid ());
78 for (i
=1; i
<= 10000000; i
++)
80 if (verbose
) printf("thread1 %d\n", pthread_self ());
93 if (verbose
) printf ("thread2 (%0x) ; pid = %d\n", arg
, getpid ());
94 for (i
=1; i
<= 10000000; i
++)
96 if (verbose
) printf("thread2 %d\n", pthread_self ());
110 if (verbose
) printf("a=%d\n", a
);
117 pthread_t tid1
, tid2
;
123 if (verbose
) printf ("pid = %d\n", getpid());
128 if (pthread_attr_init (&attr
))
130 perror ("pthread_attr_init 1");
135 #ifdef PTHREAD_SCOPE_SYSTEM
136 if (pthread_attr_setscope (&attr
, PTHREAD_SCOPE_SYSTEM
))
138 perror ("pthread_attr_setscope 1");
143 if (pthread_create (&tid1
, pthread_attr_default
, thread1
, (void *) 0xfeedface))
145 perror ("pthread_create 1");
148 if (verbose
) printf ("Made thread %d\n", tid1
);
151 if (pthread_create (&tid2
, null_attr
, thread2
, (void *) 0xdeadbeef))
153 perror ("pthread_create 2");
156 if (verbose
) printf("Made thread %d\n", tid2
);
160 for (j
= 1; j
<= 10000000; j
++)
162 if (verbose
) printf("top %d\n", pthread_self ());
177 #endif /* ifndef HAVE_PTHREAD_H */