This source file includes following definitions.
- glthread_in_use
- dummy_thread_func
- glthread_in_use
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include <config.h>
20
21
22
23 #if USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS
24
25
26
27 # include <errno.h>
28 # include <pthread.h>
29 # include <stdlib.h>
30
31 # if PTHREAD_IN_USE_DETECTION_HARD
32
33 # if defined __FreeBSD__ || defined __DragonFly__
34
35
36
37 int
38 glthread_in_use (void)
39 {
40 static int tested;
41 static int result;
42
43 if (!tested)
44 {
45 pthread_key_t key;
46 int err = pthread_key_create (&key, NULL);
47
48 if (err == ENOSYS)
49 result = 0;
50 else
51 {
52 result = 1;
53 if (err == 0)
54 pthread_key_delete (key);
55 }
56 tested = 1;
57 }
58 return result;
59 }
60
61 # else
62
63
64
65
66 static void *
67 dummy_thread_func (void *arg)
68 {
69 return arg;
70 }
71
72 int
73 glthread_in_use (void)
74 {
75 static int tested;
76 static int result;
77
78 if (!tested)
79 {
80 pthread_t thread;
81
82 if (pthread_create (&thread, NULL, dummy_thread_func, NULL) != 0)
83
84 result = 0;
85 else
86 {
87
88 void *retval;
89 if (pthread_join (thread, &retval) != 0)
90 abort ();
91 result = 1;
92 }
93 tested = 1;
94 }
95 return result;
96 }
97
98 # endif
99
100 # endif
101
102 #endif
103
104
105
106
107
108 typedef int dummy;