bart | 96f892f | 2008-03-09 16:16:06 +0000 | [diff] [blame^] | 1 | /** Test whether DRD recognizes LinuxThreads as LinuxThreads and NPTL as |
| 2 | * NPTL. |
| 3 | */ |
| 4 | |
| 5 | |
| 6 | #include <pthread.h> |
| 7 | #include <semaphore.h> |
| 8 | #include <stdio.h> |
| 9 | #include <unistd.h> |
| 10 | |
| 11 | |
| 12 | static sem_t s_sem; |
| 13 | static pid_t s_main_thread_pid; |
| 14 | |
| 15 | |
| 16 | void* thread_func(void* arg) |
| 17 | { |
| 18 | if (s_main_thread_pid == getpid()) |
| 19 | { |
| 20 | printf("NPTL or non-Linux POSIX threads implemenentation detected.\n"); |
| 21 | } |
| 22 | else |
| 23 | { |
| 24 | printf("Detected LinuxThreads as POSIX threads implemenentation.\n"); |
| 25 | } |
| 26 | sem_post(&s_sem); |
| 27 | return 0; |
| 28 | } |
| 29 | |
| 30 | int main(int argc, char** argv) |
| 31 | { |
| 32 | pthread_t threadid; |
| 33 | |
| 34 | s_main_thread_pid = getpid(); |
| 35 | sem_init(&s_sem, 0, 0); |
| 36 | pthread_create(&threadid, 0, thread_func, 0); |
| 37 | sem_wait(&s_sem); |
| 38 | pthread_join(threadid, 0); |
| 39 | sem_destroy(&s_sem); |
| 40 | return 0; |
| 41 | } |