7 /* Don't even try to compile. In fact, cause a syntax error that we can
8 look for as a compiler error message and know that we have no pthread
9 support. In that case we can just suppress the test completely. */
11 #error "no posix threads support"
15 /* OK. We have the right header. If we try to compile this and fail, then
16 there is something wrong and the user should know about it so the testsuite
17 should issue an ERROR result.. */
20 #define _MIT_POSIX_THREADS 1 /* Linux (or at least RedHat 4.0) needs this */
25 /* Under OSF 2.0 & 3.0 and HPUX 10, the second arg of pthread_create
26 is prototyped to be just a "pthread_attr_t", while under Solaris it
27 is a "pthread_attr_t *". Arg! */
29 #if defined (__osf__) || defined (__hpux__)
30 #define PTHREAD_CREATE_ARG2(arg) arg
31 #define PTHREAD_CREATE_NULL_ARG2 null_attr
32 static pthread_attr_t null_attr
;
34 #define PTHREAD_CREATE_ARG2(arg) &arg
35 #define PTHREAD_CREATE_NULL_ARG2 NULL
38 static int verbose
= 0;
44 static int from_thread1
;
45 static int from_thread2
;
48 static int full_coverage
;
50 if (verbose
) printf("common_routine (%d)\n", arg
);
64 if (from_main
&& from_thread1
&& from_thread2
)
74 if (verbose
) printf ("thread1 (%0x) ; pid = %d\n", arg
, getpid ());
75 for (i
=1; i
<= 10000000; i
++)
77 if (verbose
) printf("thread1 %d\n", pthread_self ());
90 if (verbose
) printf ("thread2 (%0x) ; pid = %d\n", arg
, getpid ());
91 for (i
=1; i
<= 10000000; i
++)
93 if (verbose
) printf("thread2 %d\n", pthread_self ());
107 if (verbose
) printf("a=%d\n", a
);
114 pthread_t tid1
, tid2
;
120 if (verbose
) printf ("pid = %d\n", getpid());
125 if (pthread_attr_init (&attr
))
127 perror ("pthread_attr_init 1");
132 #ifdef PTHREAD_SCOPE_SYSTEM
133 if (pthread_attr_setscope (&attr
, PTHREAD_SCOPE_SYSTEM
))
135 perror ("pthread_attr_setscope 1");
140 if (pthread_create (&tid1
, PTHREAD_CREATE_ARG2(attr
), thread1
, (void *) 0xfeedface))
142 perror ("pthread_create 1");
145 if (verbose
) printf ("Made thread %d\n", tid1
);
148 if (pthread_create (&tid2
, PTHREAD_CREATE_NULL_ARG2
, thread2
, (void *) 0xdeadbeef))
150 perror ("pthread_create 2");
153 if (verbose
) printf("Made thread %d\n", tid2
);
157 for (j
= 1; j
<= 10000000; j
++)
159 if (verbose
) printf("top %d\n", pthread_self ());
168 #endif /* ifndef HAVE_PTHREAD_H */
This page took 0.041594 seconds and 5 git commands to generate.