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> |
bart | 96f892f | 2008-03-09 16:16:06 +0000 | [diff] [blame] | 8 | #include <unistd.h> |
| 9 | |
| 10 | |
bart | 96f892f | 2008-03-09 16:16:06 +0000 | [diff] [blame] | 11 | static pid_t s_main_thread_pid; |
| 12 | |
| 13 | |
| 14 | void* thread_func(void* arg) |
| 15 | { |
| 16 | if (s_main_thread_pid == getpid()) |
| 17 | { |
bart | d029e46 | 2008-07-29 16:57:06 +0000 | [diff] [blame] | 18 | write(STDOUT_FILENO, "NPTL or non-Linux POSIX threads implementation detected.\n", 57); |
bart | 96f892f | 2008-03-09 16:16:06 +0000 | [diff] [blame] | 19 | } |
| 20 | else |
| 21 | { |
bart | d029e46 | 2008-07-29 16:57:06 +0000 | [diff] [blame] | 22 | write(STDOUT_FILENO, "Detected LinuxThreads as POSIX threads implementation.\n", 55); |
bart | 96f892f | 2008-03-09 16:16:06 +0000 | [diff] [blame] | 23 | } |
bart | 96f892f | 2008-03-09 16:16:06 +0000 | [diff] [blame] | 24 | return 0; |
| 25 | } |
| 26 | |
| 27 | int main(int argc, char** argv) |
| 28 | { |
| 29 | pthread_t threadid; |
| 30 | |
| 31 | s_main_thread_pid = getpid(); |
bart | 96f892f | 2008-03-09 16:16:06 +0000 | [diff] [blame] | 32 | pthread_create(&threadid, 0, thread_func, 0); |
bart | 96f892f | 2008-03-09 16:16:06 +0000 | [diff] [blame] | 33 | pthread_join(threadid, 0); |
bart | 96f892f | 2008-03-09 16:16:06 +0000 | [diff] [blame] | 34 | return 0; |
| 35 | } |