gccxml_gem 0.9.2-universal-darwin-10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. data/Rakefile +79 -0
  2. data/bin/gccxml +0 -0
  3. data/bin/gccxml_cc1plus +0 -0
  4. data/gccxml.rb +57 -0
  5. data/share/doc/gccxml-0.9/Copyright.txt +55 -0
  6. data/share/doc/gccxml-0.9/gccxml.html +168 -0
  7. data/share/doc/gccxml-0.9/gccxml.txt +293 -0
  8. data/share/gccxml-0.9/GCC/2.95/algorithm +76 -0
  9. data/share/gccxml-0.9/GCC/2.95/bitset +17 -0
  10. data/share/gccxml-0.9/GCC/2.95/cctype +24 -0
  11. data/share/gccxml-0.9/GCC/2.95/clocale +14 -0
  12. data/share/gccxml-0.9/GCC/2.95/cmath +33 -0
  13. data/share/gccxml-0.9/GCC/2.95/complex +38 -0
  14. data/share/gccxml-0.9/GCC/2.95/csetjmp +13 -0
  15. data/share/gccxml-0.9/GCC/2.95/csignal +14 -0
  16. data/share/gccxml-0.9/GCC/2.95/cstdarg +12 -0
  17. data/share/gccxml-0.9/GCC/2.95/cstddef +13 -0
  18. data/share/gccxml-0.9/GCC/2.95/cstdio +55 -0
  19. data/share/gccxml-0.9/GCC/2.95/cstdlib +66 -0
  20. data/share/gccxml-0.9/GCC/2.95/cstring +34 -0
  21. data/share/gccxml-0.9/GCC/2.95/ctime +24 -0
  22. data/share/gccxml-0.9/GCC/2.95/cwchar +65 -0
  23. data/share/gccxml-0.9/GCC/2.95/cwctype +31 -0
  24. data/share/gccxml-0.9/GCC/2.95/deque +19 -0
  25. data/share/gccxml-0.9/GCC/2.95/exception +20 -0
  26. data/share/gccxml-0.9/GCC/2.95/fstream +23 -0
  27. data/share/gccxml-0.9/GCC/2.95/functional +64 -0
  28. data/share/gccxml-0.9/GCC/2.95/gccxml_bitset +1066 -0
  29. data/share/gccxml-0.9/GCC/2.95/iomanip +20 -0
  30. data/share/gccxml-0.9/GCC/2.95/iosfwd +20 -0
  31. data/share/gccxml-0.9/GCC/2.95/iostream +27 -0
  32. data/share/gccxml-0.9/GCC/2.95/iterator +39 -0
  33. data/share/gccxml-0.9/GCC/2.95/list +19 -0
  34. data/share/gccxml-0.9/GCC/2.95/map +20 -0
  35. data/share/gccxml-0.9/GCC/2.95/memory +21 -0
  36. data/share/gccxml-0.9/GCC/2.95/new +13 -0
  37. data/share/gccxml-0.9/GCC/2.95/numeric +15 -0
  38. data/share/gccxml-0.9/GCC/2.95/pthread.h +16 -0
  39. data/share/gccxml-0.9/GCC/2.95/queue +20 -0
  40. data/share/gccxml-0.9/GCC/2.95/set +20 -0
  41. data/share/gccxml-0.9/GCC/2.95/sstream +24 -0
  42. data/share/gccxml-0.9/GCC/2.95/stack +19 -0
  43. data/share/gccxml-0.9/GCC/2.95/std/bastring.cc +524 -0
  44. data/share/gccxml-0.9/GCC/2.95/std/complext.h +397 -0
  45. data/share/gccxml-0.9/GCC/2.95/std/dcomplex.h +92 -0
  46. data/share/gccxml-0.9/GCC/2.95/std/fcomplex.h +88 -0
  47. data/share/gccxml-0.9/GCC/2.95/std/gslice_array.h +170 -0
  48. data/share/gccxml-0.9/GCC/2.95/std/indirect_array.h +157 -0
  49. data/share/gccxml-0.9/GCC/2.95/std/ldcomplex.h +96 -0
  50. data/share/gccxml-0.9/GCC/2.95/std/mask_array.h +154 -0
  51. data/share/gccxml-0.9/GCC/2.95/std/slice_array.h +156 -0
  52. data/share/gccxml-0.9/GCC/2.95/std/std_valarray.h +728 -0
  53. data/share/gccxml-0.9/GCC/2.95/std/straits.h +162 -0
  54. data/share/gccxml-0.9/GCC/2.95/std/valarray_meta.h +1035 -0
  55. data/share/gccxml-0.9/GCC/2.95/stdexcept +17 -0
  56. data/share/gccxml-0.9/GCC/2.95/stl_alloc.h +1057 -0
  57. data/share/gccxml-0.9/GCC/2.95/stl_bvector.h +836 -0
  58. data/share/gccxml-0.9/GCC/2.95/stl_deque.h +1699 -0
  59. data/share/gccxml-0.9/GCC/2.95/stl_list.h +843 -0
  60. data/share/gccxml-0.9/GCC/2.95/stl_tree.h +1331 -0
  61. data/share/gccxml-0.9/GCC/2.95/stl_vector.h +828 -0
  62. data/share/gccxml-0.9/GCC/2.95/string +26 -0
  63. data/share/gccxml-0.9/GCC/2.95/strstream +23 -0
  64. data/share/gccxml-0.9/GCC/2.95/typeinfo +11 -0
  65. data/share/gccxml-0.9/GCC/2.95/utility +25 -0
  66. data/share/gccxml-0.9/GCC/2.95/valarray +52 -0
  67. data/share/gccxml-0.9/GCC/2.95/vector +19 -0
  68. data/share/gccxml-0.9/GCC/2.96/sstream +305 -0
  69. data/share/gccxml-0.9/GCC/3.0/pthread.h +16 -0
  70. data/share/gccxml-0.9/GCC/3.1/pthread.h +16 -0
  71. data/share/gccxml-0.9/GCC/3.2/bits/fstream.tcc +500 -0
  72. data/share/gccxml-0.9/GCC/3.2/bits/gthr-default.h +581 -0
  73. data/share/gccxml-0.9/GCC/3.2/bits/istream.tcc +1207 -0
  74. data/share/gccxml-0.9/GCC/3.2/bits/locale_facets.h +1810 -0
  75. data/share/gccxml-0.9/GCC/3.2/bits/locale_facets.tcc +2397 -0
  76. data/share/gccxml-0.9/GCC/3.2/bits/messages_members.h +108 -0
  77. data/share/gccxml-0.9/GCC/3.2/bits/ostream.tcc +713 -0
  78. data/share/gccxml-0.9/GCC/3.2/bits/sstream.tcc +241 -0
  79. data/share/gccxml-0.9/GCC/3.2/bits/stl_deque.h +1682 -0
  80. data/share/gccxml-0.9/GCC/3.2/bits/stl_list.h +989 -0
  81. data/share/gccxml-0.9/GCC/3.2/bits/stl_tree.h +1462 -0
  82. data/share/gccxml-0.9/GCC/3.2/bits/stl_vector.h +1085 -0
  83. data/share/gccxml-0.9/GCC/3.2/bits/valarray_meta.h +1063 -0
  84. data/share/gccxml-0.9/GCC/3.2/fstream +579 -0
  85. data/share/gccxml-0.9/GCC/3.2/pthread.h +16 -0
  86. data/share/gccxml-0.9/GCC/3.2/sstream +384 -0
  87. data/share/gccxml-0.9/GCC/3.3/bits/fstream.tcc +530 -0
  88. data/share/gccxml-0.9/GCC/3.3/bits/list.tcc +378 -0
  89. data/share/gccxml-0.9/GCC/3.3/bits/locale_facets.h +2050 -0
  90. data/share/gccxml-0.9/GCC/3.3/bits/messages_members.h +108 -0
  91. data/share/gccxml-0.9/GCC/3.3/bits/sstream.tcc +243 -0
  92. data/share/gccxml-0.9/GCC/3.3/bits/stl_deque.h +1603 -0
  93. data/share/gccxml-0.9/GCC/3.3/bits/stl_list.h +1167 -0
  94. data/share/gccxml-0.9/GCC/3.3/bits/stl_tree.h +1462 -0
  95. data/share/gccxml-0.9/GCC/3.3/bits/stl_vector.h +992 -0
  96. data/share/gccxml-0.9/GCC/3.3/bits/valarray_meta.h +1135 -0
  97. data/share/gccxml-0.9/GCC/3.3/fstream +842 -0
  98. data/share/gccxml-0.9/GCC/3.3/gccxml_builtins.h +22 -0
  99. data/share/gccxml-0.9/GCC/3.3/sstream +638 -0
  100. data/share/gccxml-0.9/GCC/3.4/bits/gthr-default.h +664 -0
  101. data/share/gccxml-0.9/GCC/3.4/gccxml_builtins.h +91 -0
  102. data/share/gccxml-0.9/GCC/4.0/gccxml_builtins.h +128 -0
  103. data/share/gccxml-0.9/GCC/4.1/bits/gthr-default.h +618 -0
  104. data/share/gccxml-0.9/GCC/4.1/gccxml_builtins.h +131 -0
  105. data/share/gccxml-0.9/GCC/4.2/gccxml_builtins.h +131 -0
  106. data/share/gccxml-0.9/GCC/4.3/gccxml_builtins.h +182 -0
  107. data/share/gccxml-0.9/IBM/8.0/adapt_headers.sh +34 -0
  108. data/share/gccxml-0.9/IBM/8.0/stdlib.h.patch +27 -0
  109. data/share/gccxml-0.9/IBM/8.0/xstring.patch +19 -0
  110. data/share/gccxml-0.9/IBM/README +8 -0
  111. data/share/gccxml-0.9/IBM/find_flags +51 -0
  112. data/share/gccxml-0.9/IBM/find_flags_common +48 -0
  113. data/share/gccxml-0.9/Intel/find_flags +56 -0
  114. data/share/gccxml-0.9/Intel/pthread.h +16 -0
  115. data/share/gccxml-0.9/MIPSpro/7.3/exception +9 -0
  116. data/share/gccxml-0.9/MIPSpro/7.3/gccxml_mpro_internals.h +21 -0
  117. data/share/gccxml-0.9/MIPSpro/7.3/iomanip +161 -0
  118. data/share/gccxml-0.9/MIPSpro/7.3/ostream +9 -0
  119. data/share/gccxml-0.9/MIPSpro/7.3/stddef.h +9 -0
  120. data/share/gccxml-0.9/MIPSpro/7.3/stl_config.h +9 -0
  121. data/share/gccxml-0.9/MIPSpro/7.3/stl_locale.h +17 -0
  122. data/share/gccxml-0.9/MIPSpro/7.3/stl_monetary.h +14 -0
  123. data/share/gccxml-0.9/MIPSpro/7.3/stl_numeric_facets.h +13 -0
  124. data/share/gccxml-0.9/MIPSpro/7.3/stl_threads.h +11 -0
  125. data/share/gccxml-0.9/MIPSpro/7.3/string +18 -0
  126. data/share/gccxml-0.9/MIPSpro/find_flags +70 -0
  127. data/share/gccxml-0.9/MIPSpro/mipspro_defs.cxx +63 -0
  128. data/share/gccxml-0.9/Sun/5.8/Cstd.patch +156 -0
  129. data/share/gccxml-0.9/Sun/5.8/adapt_headers.sh +32 -0
  130. data/share/gccxml-0.9/Sun/5.8/std-5.10.patch +22 -0
  131. data/share/gccxml-0.9/Sun/README +8 -0
  132. data/share/gccxml-0.9/Sun/find_flags +51 -0
  133. data/share/gccxml-0.9/Sun/find_flags_common +42 -0
  134. data/share/gccxml-0.9/gccxml_config +2 -0
  135. data/share/gccxml-0.9/gccxml_identify_compiler.cc +13 -0
  136. data/share/man/man1/gccxml.1 +246 -0
  137. metadata +194 -0
@@ -0,0 +1,618 @@
1
+ /* Threads compatibility routines for libgcc2 and libobjc. */
2
+ /* Compile this one with gcc. */
3
+ /* Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
4
+ Free Software Foundation, Inc.
5
+
6
+ This file is part of GCC.
7
+
8
+ GCC is free software; you can redistribute it and/or modify it under
9
+ the terms of the GNU General Public License as published by the Free
10
+ Software Foundation; either version 2, or (at your option) any later
11
+ version.
12
+
13
+ GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16
+ for more details.
17
+
18
+ You should have received a copy of the GNU General Public License
19
+ along with GCC; see the file COPYING. If not, write to the Free
20
+ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
21
+ 02110-1301, USA. */
22
+
23
+ /* As a special exception, if you link this library with other files,
24
+ some of which are compiled with GCC, to produce an executable,
25
+ this library does not by itself cause the resulting executable
26
+ to be covered by the GNU General Public License.
27
+ This exception does not however invalidate any other reasons why
28
+ the executable file might be covered by the GNU General Public License. */
29
+
30
+ #ifndef _GLIBCXX_GCC_GTHR_POSIX_H
31
+ #define _GLIBCXX_GCC_GTHR_POSIX_H
32
+
33
+ /* POSIX threads specific definitions.
34
+ Easy, since the interface is just one-to-one mapping. */
35
+
36
+ #define __GTHREADS 1
37
+
38
+ /* Some implementations of <pthread.h> require this to be defined. */
39
+ #if !defined(_REENTRANT) && defined(__osf__)
40
+ #define _REENTRANT 1
41
+ #endif
42
+
43
+ #include <pthread.h>
44
+ #include <unistd.h>
45
+
46
+ typedef pthread_key_t __gthread_key_t;
47
+ typedef pthread_once_t __gthread_once_t;
48
+ typedef pthread_mutex_t __gthread_mutex_t;
49
+ typedef pthread_mutex_t __gthread_recursive_mutex_t;
50
+
51
+ #define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
52
+ #define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
53
+ #if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
54
+ #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER
55
+ #elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
56
+ #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
57
+ #else
58
+ #define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
59
+ #endif
60
+
61
+ #if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK && 0
62
+ # ifndef __gthrw_pragma
63
+ # define __gthrw_pragma(pragma)
64
+ # endif
65
+ # define __gthrw2(name,name2,type) \
66
+ extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
67
+ __gthrw_pragma(weak type)
68
+ # define __gthrw_(name) __gthrw_ ## name
69
+ #else
70
+ # define __gthrw2(name,name2,type)
71
+ # define __gthrw_(name) name
72
+ #endif
73
+
74
+ /* Typically, __gthrw_foo is a weak reference to symbol foo. */
75
+ #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
76
+
77
+ /* On Tru64, /usr/include/pthread.h uses #pragma extern_prefix "__" to
78
+ map a subset of the POSIX pthread API to mangled versions of their
79
+ names. */
80
+ #if defined(__osf__) && defined(_PTHREAD_USE_MANGLED_NAMES_)
81
+ #define __gthrw3(name) __gthrw2(__gthrw_ ## name, __ ## name, name)
82
+ __gthrw3(pthread_once)
83
+ __gthrw3(pthread_getspecific)
84
+ __gthrw3(pthread_setspecific)
85
+ __gthrw3(pthread_create)
86
+ __gthrw3(pthread_cancel)
87
+ __gthrw3(pthread_mutex_lock)
88
+ __gthrw3(pthread_mutex_trylock)
89
+ __gthrw3(pthread_mutex_unlock)
90
+ __gthrw3(pthread_mutex_init)
91
+ #else
92
+ __gthrw(pthread_once)
93
+ __gthrw(pthread_getspecific)
94
+ __gthrw(pthread_setspecific)
95
+ __gthrw(pthread_create)
96
+ __gthrw(pthread_cancel)
97
+ __gthrw(pthread_mutex_lock)
98
+ __gthrw(pthread_mutex_trylock)
99
+ __gthrw(pthread_mutex_unlock)
100
+ __gthrw(pthread_mutex_init)
101
+ #endif
102
+
103
+ __gthrw(pthread_key_create)
104
+ __gthrw(pthread_key_delete)
105
+ __gthrw(pthread_mutexattr_init)
106
+ __gthrw(pthread_mutexattr_settype)
107
+ __gthrw(pthread_mutexattr_destroy)
108
+
109
+
110
+ #if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)
111
+ /* Objective-C. */
112
+ #if defined(__osf__) && defined(_PTHREAD_USE_MANGLED_NAMES_)
113
+ __gthrw3(pthread_cond_broadcast)
114
+ __gthrw3(pthread_cond_destroy)
115
+ __gthrw3(pthread_cond_init)
116
+ __gthrw3(pthread_cond_signal)
117
+ __gthrw3(pthread_cond_wait)
118
+ __gthrw3(pthread_exit)
119
+ __gthrw3(pthread_mutex_destroy)
120
+ __gthrw3(pthread_self)
121
+ #else
122
+ __gthrw(pthread_cond_broadcast)
123
+ __gthrw(pthread_cond_destroy)
124
+ __gthrw(pthread_cond_init)
125
+ __gthrw(pthread_cond_signal)
126
+ __gthrw(pthread_cond_wait)
127
+ __gthrw(pthread_exit)
128
+ __gthrw(pthread_mutex_destroy)
129
+ __gthrw(pthread_self)
130
+ #endif /* __osf__ && _PTHREAD_USE_MANGLED_NAMES_ */
131
+ #ifdef _POSIX_PRIORITY_SCHEDULING
132
+ #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
133
+ __gthrw(sched_get_priority_max)
134
+ __gthrw(sched_get_priority_min)
135
+ #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
136
+ #endif /* _POSIX_PRIORITY_SCHEDULING */
137
+ __gthrw(sched_yield)
138
+ __gthrw(pthread_attr_destroy)
139
+ __gthrw(pthread_attr_init)
140
+ __gthrw(pthread_attr_setdetachstate)
141
+ #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
142
+ __gthrw(pthread_getschedparam)
143
+ __gthrw(pthread_setschedparam)
144
+ #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
145
+ #endif /* _LIBOBJC || _LIBOBJC_WEAK */
146
+
147
+ #if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK
148
+
149
+ static inline int
150
+ __gthread_active_p (void)
151
+ {
152
+ static void *const __gthread_active_ptr
153
+ = __extension__ (void *) &__gthrw_(pthread_cancel);
154
+ return __gthread_active_ptr != 0;
155
+ }
156
+
157
+ #else /* not __GXX_WEAK__ */
158
+
159
+ static inline int
160
+ __gthread_active_p (void)
161
+ {
162
+ return 1;
163
+ }
164
+
165
+ #endif /* __GXX_WEAK__ */
166
+
167
+ #ifdef _LIBOBJC
168
+
169
+ /* This is the config.h file in libobjc/ */
170
+ #include <config.h>
171
+
172
+ #ifdef HAVE_SCHED_H
173
+ # include <sched.h>
174
+ #endif
175
+
176
+ /* Key structure for maintaining thread specific storage */
177
+ static pthread_key_t _objc_thread_storage;
178
+ static pthread_attr_t _objc_thread_attribs;
179
+
180
+ /* Thread local storage for a single thread */
181
+ static void *thread_local_storage = NULL;
182
+
183
+ /* Backend initialization functions */
184
+
185
+ /* Initialize the threads subsystem. */
186
+ static inline int
187
+ __gthread_objc_init_thread_system (void)
188
+ {
189
+ if (__gthread_active_p ())
190
+ {
191
+ /* Initialize the thread storage key. */
192
+ if (__gthrw_(pthread_key_create) (&_objc_thread_storage, NULL) == 0)
193
+ {
194
+ /* The normal default detach state for threads is
195
+ * PTHREAD_CREATE_JOINABLE which causes threads to not die
196
+ * when you think they should. */
197
+ if (__gthrw_(pthread_attr_init) (&_objc_thread_attribs) == 0
198
+ && __gthrw_(pthread_attr_setdetachstate) (&_objc_thread_attribs,
199
+ PTHREAD_CREATE_DETACHED) == 0)
200
+ return 0;
201
+ }
202
+ }
203
+
204
+ return -1;
205
+ }
206
+
207
+ /* Close the threads subsystem. */
208
+ static inline int
209
+ __gthread_objc_close_thread_system (void)
210
+ {
211
+ if (__gthread_active_p ()
212
+ && __gthrw_(pthread_key_delete) (_objc_thread_storage) == 0
213
+ && __gthrw_(pthread_attr_destroy) (&_objc_thread_attribs) == 0)
214
+ return 0;
215
+
216
+ return -1;
217
+ }
218
+
219
+ /* Backend thread functions */
220
+
221
+ /* Create a new thread of execution. */
222
+ static inline objc_thread_t
223
+ __gthread_objc_thread_detach (void (*func)(void *), void *arg)
224
+ {
225
+ objc_thread_t thread_id;
226
+ pthread_t new_thread_handle;
227
+
228
+ if (!__gthread_active_p ())
229
+ return NULL;
230
+
231
+ if (!(__gthrw_(pthread_create) (&new_thread_handle, NULL, (void *) func, arg)))
232
+ thread_id = (objc_thread_t) new_thread_handle;
233
+ else
234
+ thread_id = NULL;
235
+
236
+ return thread_id;
237
+ }
238
+
239
+ /* Set the current thread's priority. */
240
+ static inline int
241
+ __gthread_objc_thread_set_priority (int priority)
242
+ {
243
+ if (!__gthread_active_p ())
244
+ return -1;
245
+ else
246
+ {
247
+ #ifdef _POSIX_PRIORITY_SCHEDULING
248
+ #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
249
+ pthread_t thread_id = __gthrw_(pthread_self) ();
250
+ int policy;
251
+ struct sched_param params;
252
+ int priority_min, priority_max;
253
+
254
+ if (__gthrw_(pthread_getschedparam) (thread_id, &policy, &params) == 0)
255
+ {
256
+ if ((priority_max = __gthrw_(sched_get_priority_max) (policy)) == -1)
257
+ return -1;
258
+
259
+ if ((priority_min = __gthrw_(sched_get_priority_min) (policy)) == -1)
260
+ return -1;
261
+
262
+ if (priority > priority_max)
263
+ priority = priority_max;
264
+ else if (priority < priority_min)
265
+ priority = priority_min;
266
+ params.sched_priority = priority;
267
+
268
+ /*
269
+ * The solaris 7 and several other man pages incorrectly state that
270
+ * this should be a pointer to policy but pthread.h is universally
271
+ * at odds with this.
272
+ */
273
+ if (__gthrw_(pthread_setschedparam) (thread_id, policy, &params) == 0)
274
+ return 0;
275
+ }
276
+ #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
277
+ #endif /* _POSIX_PRIORITY_SCHEDULING */
278
+ return -1;
279
+ }
280
+ }
281
+
282
+ /* Return the current thread's priority. */
283
+ static inline int
284
+ __gthread_objc_thread_get_priority (void)
285
+ {
286
+ #ifdef _POSIX_PRIORITY_SCHEDULING
287
+ #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
288
+ if (__gthread_active_p ())
289
+ {
290
+ int policy;
291
+ struct sched_param params;
292
+
293
+ if (__gthrw_(pthread_getschedparam) (__gthrw_(pthread_self) (), &policy, &params) == 0)
294
+ return params.sched_priority;
295
+ else
296
+ return -1;
297
+ }
298
+ else
299
+ #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
300
+ #endif /* _POSIX_PRIORITY_SCHEDULING */
301
+ return OBJC_THREAD_INTERACTIVE_PRIORITY;
302
+ }
303
+
304
+ /* Yield our process time to another thread. */
305
+ static inline void
306
+ __gthread_objc_thread_yield (void)
307
+ {
308
+ if (__gthread_active_p ())
309
+ __gthrw_(sched_yield) ();
310
+ }
311
+
312
+ /* Terminate the current thread. */
313
+ static inline int
314
+ __gthread_objc_thread_exit (void)
315
+ {
316
+ if (__gthread_active_p ())
317
+ /* exit the thread */
318
+ __gthrw_(pthread_exit) (&__objc_thread_exit_status);
319
+
320
+ /* Failed if we reached here */
321
+ return -1;
322
+ }
323
+
324
+ /* Returns an integer value which uniquely describes a thread. */
325
+ static inline objc_thread_t
326
+ __gthread_objc_thread_id (void)
327
+ {
328
+ if (__gthread_active_p ())
329
+ return (objc_thread_t) __gthrw_(pthread_self) ();
330
+ else
331
+ return (objc_thread_t) 1;
332
+ }
333
+
334
+ /* Sets the thread's local storage pointer. */
335
+ static inline int
336
+ __gthread_objc_thread_set_data (void *value)
337
+ {
338
+ if (__gthread_active_p ())
339
+ return __gthrw_(pthread_setspecific) (_objc_thread_storage, value);
340
+ else
341
+ {
342
+ thread_local_storage = value;
343
+ return 0;
344
+ }
345
+ }
346
+
347
+ /* Returns the thread's local storage pointer. */
348
+ static inline void *
349
+ __gthread_objc_thread_get_data (void)
350
+ {
351
+ if (__gthread_active_p ())
352
+ return __gthrw_(pthread_getspecific) (_objc_thread_storage);
353
+ else
354
+ return thread_local_storage;
355
+ }
356
+
357
+ /* Backend mutex functions */
358
+
359
+ /* Allocate a mutex. */
360
+ static inline int
361
+ __gthread_objc_mutex_allocate (objc_mutex_t mutex)
362
+ {
363
+ if (__gthread_active_p ())
364
+ {
365
+ mutex->backend = objc_malloc (sizeof (pthread_mutex_t));
366
+
367
+ if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex->backend, NULL))
368
+ {
369
+ objc_free (mutex->backend);
370
+ mutex->backend = NULL;
371
+ return -1;
372
+ }
373
+ }
374
+
375
+ return 0;
376
+ }
377
+
378
+ /* Deallocate a mutex. */
379
+ static inline int
380
+ __gthread_objc_mutex_deallocate (objc_mutex_t mutex)
381
+ {
382
+ if (__gthread_active_p ())
383
+ {
384
+ int count;
385
+
386
+ /*
387
+ * Posix Threads specifically require that the thread be unlocked
388
+ * for __gthrw_(pthread_mutex_destroy) to work.
389
+ */
390
+
391
+ do
392
+ {
393
+ count = __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend);
394
+ if (count < 0)
395
+ return -1;
396
+ }
397
+ while (count);
398
+
399
+ if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex->backend))
400
+ return -1;
401
+
402
+ objc_free (mutex->backend);
403
+ mutex->backend = NULL;
404
+ }
405
+ return 0;
406
+ }
407
+
408
+ /* Grab a lock on a mutex. */
409
+ static inline int
410
+ __gthread_objc_mutex_lock (objc_mutex_t mutex)
411
+ {
412
+ if (__gthread_active_p ()
413
+ && __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex->backend) != 0)
414
+ {
415
+ return -1;
416
+ }
417
+
418
+ return 0;
419
+ }
420
+
421
+ /* Try to grab a lock on a mutex. */
422
+ static inline int
423
+ __gthread_objc_mutex_trylock (objc_mutex_t mutex)
424
+ {
425
+ if (__gthread_active_p ()
426
+ && __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex->backend) != 0)
427
+ {
428
+ return -1;
429
+ }
430
+
431
+ return 0;
432
+ }
433
+
434
+ /* Unlock the mutex */
435
+ static inline int
436
+ __gthread_objc_mutex_unlock (objc_mutex_t mutex)
437
+ {
438
+ if (__gthread_active_p ()
439
+ && __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend) != 0)
440
+ {
441
+ return -1;
442
+ }
443
+
444
+ return 0;
445
+ }
446
+
447
+ /* Backend condition mutex functions */
448
+
449
+ /* Allocate a condition. */
450
+ static inline int
451
+ __gthread_objc_condition_allocate (objc_condition_t condition)
452
+ {
453
+ if (__gthread_active_p ())
454
+ {
455
+ condition->backend = objc_malloc (sizeof (pthread_cond_t));
456
+
457
+ if (__gthrw_(pthread_cond_init) ((pthread_cond_t *) condition->backend, NULL))
458
+ {
459
+ objc_free (condition->backend);
460
+ condition->backend = NULL;
461
+ return -1;
462
+ }
463
+ }
464
+
465
+ return 0;
466
+ }
467
+
468
+ /* Deallocate a condition. */
469
+ static inline int
470
+ __gthread_objc_condition_deallocate (objc_condition_t condition)
471
+ {
472
+ if (__gthread_active_p ())
473
+ {
474
+ if (__gthrw_(pthread_cond_destroy) ((pthread_cond_t *) condition->backend))
475
+ return -1;
476
+
477
+ objc_free (condition->backend);
478
+ condition->backend = NULL;
479
+ }
480
+ return 0;
481
+ }
482
+
483
+ /* Wait on the condition */
484
+ static inline int
485
+ __gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex)
486
+ {
487
+ if (__gthread_active_p ())
488
+ return __gthrw_(pthread_cond_wait) ((pthread_cond_t *) condition->backend,
489
+ (pthread_mutex_t *) mutex->backend);
490
+ else
491
+ return 0;
492
+ }
493
+
494
+ /* Wake up all threads waiting on this condition. */
495
+ static inline int
496
+ __gthread_objc_condition_broadcast (objc_condition_t condition)
497
+ {
498
+ if (__gthread_active_p ())
499
+ return __gthrw_(pthread_cond_broadcast) ((pthread_cond_t *) condition->backend);
500
+ else
501
+ return 0;
502
+ }
503
+
504
+ /* Wake up one thread waiting on this condition. */
505
+ static inline int
506
+ __gthread_objc_condition_signal (objc_condition_t condition)
507
+ {
508
+ if (__gthread_active_p ())
509
+ return __gthrw_(pthread_cond_signal) ((pthread_cond_t *) condition->backend);
510
+ else
511
+ return 0;
512
+ }
513
+
514
+ #else /* _LIBOBJC */
515
+
516
+ static inline int
517
+ __gthread_once (__gthread_once_t *once, void (*func) (void))
518
+ {
519
+ if (__gthread_active_p ())
520
+ return __gthrw_(pthread_once) (once, func);
521
+ else
522
+ return -1;
523
+ }
524
+
525
+ static inline int
526
+ __gthread_key_create (__gthread_key_t *key, void (*dtor) (void *))
527
+ {
528
+ return __gthrw_(pthread_key_create) (key, dtor);
529
+ }
530
+
531
+ static inline int
532
+ __gthread_key_delete (__gthread_key_t key)
533
+ {
534
+ return __gthrw_(pthread_key_delete) (key);
535
+ }
536
+
537
+ static inline void *
538
+ __gthread_getspecific (__gthread_key_t key)
539
+ {
540
+ return __gthrw_(pthread_getspecific) (key);
541
+ }
542
+
543
+ static inline int
544
+ __gthread_setspecific (__gthread_key_t key, const void *ptr)
545
+ {
546
+ return __gthrw_(pthread_setspecific) (key, ptr);
547
+ }
548
+
549
+ static inline int
550
+ __gthread_mutex_lock (__gthread_mutex_t *mutex)
551
+ {
552
+ if (__gthread_active_p ())
553
+ return __gthrw_(pthread_mutex_lock) (mutex);
554
+ else
555
+ return 0;
556
+ }
557
+
558
+ static inline int
559
+ __gthread_mutex_trylock (__gthread_mutex_t *mutex)
560
+ {
561
+ if (__gthread_active_p ())
562
+ return __gthrw_(pthread_mutex_trylock) (mutex);
563
+ else
564
+ return 0;
565
+ }
566
+
567
+ static inline int
568
+ __gthread_mutex_unlock (__gthread_mutex_t *mutex)
569
+ {
570
+ if (__gthread_active_p ())
571
+ return __gthrw_(pthread_mutex_unlock) (mutex);
572
+ else
573
+ return 0;
574
+ }
575
+
576
+ #ifndef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
577
+ static inline int
578
+ __gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *mutex)
579
+ {
580
+ if (__gthread_active_p ())
581
+ {
582
+ pthread_mutexattr_t attr;
583
+ int r;
584
+
585
+ r = __gthrw_(pthread_mutexattr_init) (&attr);
586
+ if (!r)
587
+ r = __gthrw_(pthread_mutexattr_settype) (&attr, PTHREAD_MUTEX_RECURSIVE);
588
+ if (!r)
589
+ r = __gthrw_(pthread_mutex_init) (mutex, &attr);
590
+ if (!r)
591
+ r = __gthrw_(pthread_mutexattr_destroy) (&attr);
592
+ return r;
593
+ }
594
+ return 0;
595
+ }
596
+ #endif
597
+
598
+ static inline int
599
+ __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex)
600
+ {
601
+ return __gthread_mutex_lock (mutex);
602
+ }
603
+
604
+ static inline int
605
+ __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex)
606
+ {
607
+ return __gthread_mutex_trylock (mutex);
608
+ }
609
+
610
+ static inline int
611
+ __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex)
612
+ {
613
+ return __gthread_mutex_unlock (mutex);
614
+ }
615
+
616
+ #endif /* _LIBOBJC */
617
+
618
+ #endif /* ! _GLIBCXX_GCC_GTHR_POSIX_H */