cmake/Modules/CheckForPthreads.c

42 lines
706 B
C
Raw Normal View History

#include <pthread.h>
2016-07-09 11:21:54 +02:00
#include <stdio.h>
#include <unistd.h>
void* runner(void*);
int res = 0;
#ifdef __CLASSIC_C__
2016-07-09 11:21:54 +02:00
int main()
{
int ac;
2016-07-09 11:21:54 +02:00
char* av[];
#else
2016-07-09 11:21:54 +02:00
int main(int ac, char* av[])
{
#endif
pthread_t tid[2];
pthread_create(&tid[0], 0, runner, (void*)1);
pthread_create(&tid[1], 0, runner, (void*)2);
2013-03-16 19:13:01 +02:00
2016-03-13 13:35:51 +01:00
#if defined(__BEOS__) && !defined(__ZETA__) /* (no usleep on BeOS 5.) */
usleep(1); /* for strange behavior on single-processor sun */
#endif
pthread_join(tid[0], 0);
pthread_join(tid[1], 0);
2016-07-09 11:21:54 +02:00
if (ac > 1000) {
return *av[0];
}
return res;
}
void* runner(void* args)
{
int cc;
2016-07-09 11:21:54 +02:00
for (cc = 0; cc < 10; cc++) {
2015-11-17 17:22:37 +01:00
printf("%p CC: %d\n", args, cc);
2016-07-09 11:21:54 +02:00
}
res++;
return 0;
}