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,664 @@
1
+ /* Threads compatibility routines for libgcc2 and libobjc. */
2
+ /* Compile this one with gcc. */
3
+ /* Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003
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, 59 Temple Place - Suite 330, Boston, MA
21
+ 02111-1307, 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 && defined __GNUC_RH_RELEASE__ \
62
+ && ((__GNUC__ == 3 && __GNUC_MINOR__ == 4 && (__GNUC_PATCHLEVEL__ > 4 || (__GNUC_PATCHLEVEL__ == 4 && __GNUC_RH_RELEASE__ > 2))) \
63
+ || (__GNUC__ == 4 && __GNUC_MINOR__ == 0 && (__GNUC_PATCHLEVEL__ > 2 || (__GNUC_PATCHLEVEL__ == 2 && __GNUC_RH_RELEASE__ > 6)))) \
64
+ && ! defined __attribute__
65
+ # define __gthrw(name) \
66
+ extern __typeof(name) __gthrw_ ## name
67
+
68
+
69
+ __gthrw(pthread_once);
70
+ __gthrw(pthread_key_create);
71
+ __gthrw(pthread_key_delete);
72
+ __gthrw(pthread_getspecific);
73
+ __gthrw(pthread_setspecific);
74
+ __gthrw(pthread_create);
75
+
76
+ __gthrw(pthread_mutex_lock);
77
+ __gthrw(pthread_mutex_trylock);
78
+ __gthrw(pthread_mutex_unlock);
79
+ __gthrw(pthread_mutexattr_init);
80
+ __gthrw(pthread_mutexattr_settype);
81
+ __gthrw(pthread_mutexattr_destroy);
82
+
83
+ __gthrw(pthread_mutex_init);
84
+
85
+ # if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)
86
+ /* Objective-C. */
87
+ __gthrw(pthread_cond_broadcast);
88
+ __gthrw(pthread_cond_destroy);
89
+ __gthrw(pthread_cond_init);
90
+ __gthrw(pthread_cond_signal);
91
+ __gthrw(pthread_cond_wait);
92
+ __gthrw(pthread_exit);
93
+ __gthrw(pthread_mutex_destroy);
94
+ __gthrw(pthread_self);
95
+ /* These really should be protected by _POSIX_PRIORITY_SCHEDULING, but
96
+ we use them inside a _POSIX_THREAD_PRIORITY_SCHEDULING block. */
97
+ # ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
98
+ __gthrw(sched_get_priority_max);
99
+ __gthrw(sched_get_priority_min);
100
+ # endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
101
+ __gthrw(sched_yield);
102
+ __gthrw(pthread_attr_destroy);
103
+ __gthrw(pthread_attr_init);
104
+ __gthrw(pthread_attr_setdetachstate);
105
+ # ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
106
+ __gthrw(pthread_getschedparam);
107
+ __gthrw(pthread_setschedparam);
108
+ # endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
109
+ # endif /* _LIBOBJC || _LIBOBJC_WEAK */
110
+ #else
111
+ # if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK
112
+ #pragma weak pthread_once
113
+ #pragma weak pthread_key_create
114
+ #pragma weak pthread_key_delete
115
+ #pragma weak pthread_getspecific
116
+ #pragma weak pthread_setspecific
117
+ #pragma weak pthread_create
118
+
119
+ #pragma weak pthread_mutex_lock
120
+ #pragma weak pthread_mutex_trylock
121
+ #pragma weak pthread_mutex_unlock
122
+ #pragma weak pthread_mutexattr_init
123
+ #pragma weak pthread_mutexattr_settype
124
+ #pragma weak pthread_mutexattr_destroy
125
+
126
+ #pragma weak pthread_mutex_init
127
+
128
+ #if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)
129
+ /* Objective-C. */
130
+ #pragma weak pthread_cond_broadcast
131
+ #pragma weak pthread_cond_destroy
132
+ #pragma weak pthread_cond_init
133
+ #pragma weak pthread_cond_signal
134
+ #pragma weak pthread_cond_wait
135
+ #pragma weak pthread_exit
136
+ #pragma weak pthread_mutex_destroy
137
+ #pragma weak pthread_self
138
+ /* These really should be protected by _POSIX_PRIORITY_SCHEDULING, but
139
+ we use them inside a _POSIX_THREAD_PRIORITY_SCHEDULING block. */
140
+ #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
141
+ #pragma weak sched_get_priority_max
142
+ #pragma weak sched_get_priority_min
143
+ #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
144
+ #pragma weak sched_yield
145
+ #pragma weak pthread_attr_destroy
146
+ #pragma weak pthread_attr_init
147
+ #pragma weak pthread_attr_setdetachstate
148
+ #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
149
+ #pragma weak pthread_getschedparam
150
+ #pragma weak pthread_setschedparam
151
+ #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
152
+ #endif /* _LIBOBJC || _LIBOBJC_WEAK */
153
+ #endif /* __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK */
154
+
155
+ #define __gthrw_pthread_once pthread_once
156
+ #define __gthrw_pthread_key_create pthread_key_create
157
+ #define __gthrw_pthread_key_delete pthread_key_delete
158
+ #define __gthrw_pthread_getspecific pthread_getspecific
159
+ #define __gthrw_pthread_setspecific pthread_setspecific
160
+ #define __gthrw_pthread_create pthread_create
161
+
162
+ #define __gthrw_pthread_mutex_lock pthread_mutex_lock
163
+ #define __gthrw_pthread_mutex_trylock pthread_mutex_trylock
164
+ #define __gthrw_pthread_mutex_unlock pthread_mutex_unlock
165
+ #define __gthrw_pthread_mutexattr_init pthread_mutexattr_init
166
+ #define __gthrw_pthread_mutexattr_settype pthread_mutexattr_settype
167
+ #define __gthrw_pthread_mutexattr_destroy pthread_mutexattr_destroy
168
+
169
+ #define __gthrw_pthread_mutex_init pthread_mutex_init
170
+
171
+ #if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)
172
+ /* Objective-C. */
173
+ #define __gthrw_pthread_cond_broadcast pthread_cond_broadcast
174
+ #define __gthrw_pthread_cond_destroy pthread_cond_destroy
175
+ #define __gthrw_pthread_cond_init pthread_cond_init
176
+ #define __gthrw_pthread_cond_signal pthread_cond_signal
177
+ #define __gthrw_pthread_cond_wait pthread_cond_wait
178
+ #define __gthrw_pthread_exit pthread_exit
179
+ #define __gthrw_pthread_mutex_destroy pthread_mutex_destroy
180
+ #define __gthrw_pthread_self pthread_self
181
+ /* These really should be protected by _POSIX_PRIORITY_SCHEDULING, but
182
+ we use them inside a _POSIX_THREAD_PRIORITY_SCHEDULING block. */
183
+ #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
184
+ #define __gthrw_sched_get_priority_max sched_get_priority_max
185
+ #define __gthrw_sched_get_priority_min sched_get_priority_min
186
+ #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
187
+ #define __gthrw_sched_yield sched_yield
188
+ #define __gthrw_pthread_attr_destroy pthread_attr_destroy
189
+ #define __gthrw_pthread_attr_init pthread_attr_init
190
+ #define __gthrw_pthread_attr_setdetachstate pthread_attr_setdetachstate
191
+ #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
192
+ #define __gthrw_pthread_getschedparam pthread_getschedparam
193
+ #define __gthrw_pthread_setschedparam pthread_setschedparam
194
+ #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
195
+ #endif /* _LIBOBJC || _LIBOBJC_WEAK */
196
+ #endif
197
+
198
+
199
+ #if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK
200
+
201
+ static inline int
202
+ __gthread_active_p (void)
203
+ {
204
+ static void *const __gthread_active_ptr = (void *) &__gthrw_pthread_create;
205
+ return __gthread_active_ptr != 0;
206
+ }
207
+
208
+ #else /* not __GXX_WEAK__ */
209
+
210
+ static inline int
211
+ __gthread_active_p (void)
212
+ {
213
+ return 1;
214
+ }
215
+
216
+ #endif /* __GXX_WEAK__ */
217
+
218
+ #ifdef _LIBOBJC
219
+
220
+ /* This is the config.h file in libobjc/ */
221
+ #include <config.h>
222
+
223
+ #ifdef HAVE_SCHED_H
224
+ # include <sched.h>
225
+ #endif
226
+
227
+ /* Key structure for maintaining thread specific storage */
228
+ static pthread_key_t _objc_thread_storage;
229
+ static pthread_attr_t _objc_thread_attribs;
230
+
231
+ /* Thread local storage for a single thread */
232
+ static void *thread_local_storage = NULL;
233
+
234
+ /* Backend initialization functions */
235
+
236
+ /* Initialize the threads subsystem. */
237
+ static inline int
238
+ __gthread_objc_init_thread_system (void)
239
+ {
240
+ if (__gthread_active_p ())
241
+ {
242
+ /* Initialize the thread storage key */
243
+ if (__gthrw_pthread_key_create (&_objc_thread_storage, NULL) == 0)
244
+ {
245
+ /* The normal default detach state for threads is
246
+ * PTHREAD_CREATE_JOINABLE which causes threads to not die
247
+ * when you think they should. */
248
+ if (__gthrw_pthread_attr_init (&_objc_thread_attribs) == 0
249
+ && __gthrw_pthread_attr_setdetachstate (&_objc_thread_attribs,
250
+ PTHREAD_CREATE_DETACHED) == 0)
251
+ return 0;
252
+ }
253
+ }
254
+
255
+ return -1;
256
+ }
257
+
258
+ /* Close the threads subsystem. */
259
+ static inline int
260
+ __gthread_objc_close_thread_system (void)
261
+ {
262
+ if (__gthread_active_p ()
263
+ && __gthrw_pthread_key_delete (_objc_thread_storage) == 0
264
+ && __gthrw_pthread_attr_destroy (&_objc_thread_attribs) == 0)
265
+ return 0;
266
+
267
+ return -1;
268
+ }
269
+
270
+ /* Backend thread functions */
271
+
272
+ /* Create a new thread of execution. */
273
+ static inline objc_thread_t
274
+ __gthread_objc_thread_detach (void (*func)(void *), void *arg)
275
+ {
276
+ objc_thread_t thread_id;
277
+ pthread_t new_thread_handle;
278
+
279
+ if (!__gthread_active_p ())
280
+ return NULL;
281
+
282
+ if (!(__gthrw_pthread_create (&new_thread_handle, NULL, (void *) func, arg)))
283
+ thread_id = (objc_thread_t) new_thread_handle;
284
+ else
285
+ thread_id = NULL;
286
+
287
+ return thread_id;
288
+ }
289
+
290
+ /* Set the current thread's priority. */
291
+ static inline int
292
+ __gthread_objc_thread_set_priority (int priority)
293
+ {
294
+ if (!__gthread_active_p ())
295
+ return -1;
296
+ else
297
+ {
298
+ #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
299
+ pthread_t thread_id = __gthrw_pthread_self ();
300
+ int policy;
301
+ struct sched_param params;
302
+ int priority_min, priority_max;
303
+
304
+ if (__gthrw_pthread_getschedparam (thread_id, &policy, &params) == 0)
305
+ {
306
+ if ((priority_max = __gthrw_sched_get_priority_max (policy)) == -1)
307
+ return -1;
308
+
309
+ if ((priority_min = __gthrw_sched_get_priority_min (policy)) == -1)
310
+ return -1;
311
+
312
+ if (priority > priority_max)
313
+ priority = priority_max;
314
+ else if (priority < priority_min)
315
+ priority = priority_min;
316
+ params.sched_priority = priority;
317
+
318
+ /*
319
+ * The solaris 7 and several other man pages incorrectly state that
320
+ * this should be a pointer to policy but pthread.h is universally
321
+ * at odds with this.
322
+ */
323
+ if (__gthrw_pthread_setschedparam (thread_id, policy, &params) == 0)
324
+ return 0;
325
+ }
326
+ #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
327
+ return -1;
328
+ }
329
+ }
330
+
331
+ /* Return the current thread's priority. */
332
+ static inline int
333
+ __gthread_objc_thread_get_priority (void)
334
+ {
335
+ #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
336
+ if (__gthread_active_p ())
337
+ {
338
+ int policy;
339
+ struct sched_param params;
340
+
341
+ if (__gthrw_pthread_getschedparam (__gthrw_pthread_self (), &policy, &params) == 0)
342
+ return params.sched_priority;
343
+ else
344
+ return -1;
345
+ }
346
+ else
347
+ #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
348
+ return OBJC_THREAD_INTERACTIVE_PRIORITY;
349
+ }
350
+
351
+ /* Yield our process time to another thread. */
352
+ static inline void
353
+ __gthread_objc_thread_yield (void)
354
+ {
355
+ if (__gthread_active_p ())
356
+ __gthrw_sched_yield ();
357
+ }
358
+
359
+ /* Terminate the current thread. */
360
+ static inline int
361
+ __gthread_objc_thread_exit (void)
362
+ {
363
+ if (__gthread_active_p ())
364
+ /* exit the thread */
365
+ __gthrw_pthread_exit (&__objc_thread_exit_status);
366
+
367
+ /* Failed if we reached here */
368
+ return -1;
369
+ }
370
+
371
+ /* Returns an integer value which uniquely describes a thread. */
372
+ static inline objc_thread_t
373
+ __gthread_objc_thread_id (void)
374
+ {
375
+ if (__gthread_active_p ())
376
+ return (objc_thread_t) __gthrw_pthread_self ();
377
+ else
378
+ return (objc_thread_t) 1;
379
+ }
380
+
381
+ /* Sets the thread's local storage pointer. */
382
+ static inline int
383
+ __gthread_objc_thread_set_data (void *value)
384
+ {
385
+ if (__gthread_active_p ())
386
+ return __gthrw_pthread_setspecific (_objc_thread_storage, value);
387
+ else
388
+ {
389
+ thread_local_storage = value;
390
+ return 0;
391
+ }
392
+ }
393
+
394
+ /* Returns the thread's local storage pointer. */
395
+ static inline void *
396
+ __gthread_objc_thread_get_data (void)
397
+ {
398
+ if (__gthread_active_p ())
399
+ return __gthrw_pthread_getspecific (_objc_thread_storage);
400
+ else
401
+ return thread_local_storage;
402
+ }
403
+
404
+ /* Backend mutex functions */
405
+
406
+ /* Allocate a mutex. */
407
+ static inline int
408
+ __gthread_objc_mutex_allocate (objc_mutex_t mutex)
409
+ {
410
+ if (__gthread_active_p ())
411
+ {
412
+ mutex->backend = objc_malloc (sizeof (pthread_mutex_t));
413
+
414
+ if (__gthrw_pthread_mutex_init ((pthread_mutex_t *) mutex->backend, NULL))
415
+ {
416
+ objc_free (mutex->backend);
417
+ mutex->backend = NULL;
418
+ return -1;
419
+ }
420
+ }
421
+
422
+ return 0;
423
+ }
424
+
425
+ /* Deallocate a mutex. */
426
+ static inline int
427
+ __gthread_objc_mutex_deallocate (objc_mutex_t mutex)
428
+ {
429
+ if (__gthread_active_p ())
430
+ {
431
+ int count;
432
+
433
+ /*
434
+ * Posix Threads specifically require that the thread be unlocked
435
+ * for __gthrw_pthread_mutex_destroy to work.
436
+ */
437
+
438
+ do
439
+ {
440
+ count = __gthrw_pthread_mutex_unlock ((pthread_mutex_t *) mutex->backend);
441
+ if (count < 0)
442
+ return -1;
443
+ }
444
+ while (count);
445
+
446
+ if (__gthrw_pthread_mutex_destroy ((pthread_mutex_t *) mutex->backend))
447
+ return -1;
448
+
449
+ objc_free (mutex->backend);
450
+ mutex->backend = NULL;
451
+ }
452
+ return 0;
453
+ }
454
+
455
+ /* Grab a lock on a mutex. */
456
+ static inline int
457
+ __gthread_objc_mutex_lock (objc_mutex_t mutex)
458
+ {
459
+ if (__gthread_active_p ()
460
+ && __gthrw_pthread_mutex_lock ((pthread_mutex_t *) mutex->backend) != 0)
461
+ {
462
+ return -1;
463
+ }
464
+
465
+ return 0;
466
+ }
467
+
468
+ /* Try to grab a lock on a mutex. */
469
+ static inline int
470
+ __gthread_objc_mutex_trylock (objc_mutex_t mutex)
471
+ {
472
+ if (__gthread_active_p ()
473
+ && __gthrw_pthread_mutex_trylock ((pthread_mutex_t *) mutex->backend) != 0)
474
+ {
475
+ return -1;
476
+ }
477
+
478
+ return 0;
479
+ }
480
+
481
+ /* Unlock the mutex */
482
+ static inline int
483
+ __gthread_objc_mutex_unlock (objc_mutex_t mutex)
484
+ {
485
+ if (__gthread_active_p ()
486
+ && __gthrw_pthread_mutex_unlock ((pthread_mutex_t *) mutex->backend) != 0)
487
+ {
488
+ return -1;
489
+ }
490
+
491
+ return 0;
492
+ }
493
+
494
+ /* Backend condition mutex functions */
495
+
496
+ /* Allocate a condition. */
497
+ static inline int
498
+ __gthread_objc_condition_allocate (objc_condition_t condition)
499
+ {
500
+ if (__gthread_active_p ())
501
+ {
502
+ condition->backend = objc_malloc (sizeof (pthread_cond_t));
503
+
504
+ if (__gthrw_pthread_cond_init ((pthread_cond_t *) condition->backend, NULL))
505
+ {
506
+ objc_free (condition->backend);
507
+ condition->backend = NULL;
508
+ return -1;
509
+ }
510
+ }
511
+
512
+ return 0;
513
+ }
514
+
515
+ /* Deallocate a condition. */
516
+ static inline int
517
+ __gthread_objc_condition_deallocate (objc_condition_t condition)
518
+ {
519
+ if (__gthread_active_p ())
520
+ {
521
+ if (__gthrw_pthread_cond_destroy ((pthread_cond_t *) condition->backend))
522
+ return -1;
523
+
524
+ objc_free (condition->backend);
525
+ condition->backend = NULL;
526
+ }
527
+ return 0;
528
+ }
529
+
530
+ /* Wait on the condition */
531
+ static inline int
532
+ __gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex)
533
+ {
534
+ if (__gthread_active_p ())
535
+ return __gthrw_pthread_cond_wait ((pthread_cond_t *) condition->backend,
536
+ (pthread_mutex_t *) mutex->backend);
537
+ else
538
+ return 0;
539
+ }
540
+
541
+ /* Wake up all threads waiting on this condition. */
542
+ static inline int
543
+ __gthread_objc_condition_broadcast (objc_condition_t condition)
544
+ {
545
+ if (__gthread_active_p ())
546
+ return __gthrw_pthread_cond_broadcast ((pthread_cond_t *) condition->backend);
547
+ else
548
+ return 0;
549
+ }
550
+
551
+ /* Wake up one thread waiting on this condition. */
552
+ static inline int
553
+ __gthread_objc_condition_signal (objc_condition_t condition)
554
+ {
555
+ if (__gthread_active_p ())
556
+ return __gthrw_pthread_cond_signal ((pthread_cond_t *) condition->backend);
557
+ else
558
+ return 0;
559
+ }
560
+
561
+ #else /* _LIBOBJC */
562
+
563
+ static inline int
564
+ __gthread_once (__gthread_once_t *once, void (*func) (void))
565
+ {
566
+ if (__gthread_active_p ())
567
+ return __gthrw_pthread_once (once, func);
568
+ else
569
+ return -1;
570
+ }
571
+
572
+ static inline int
573
+ __gthread_key_create (__gthread_key_t *key, void (*dtor) (void *))
574
+ {
575
+ return __gthrw_pthread_key_create (key, dtor);
576
+ }
577
+
578
+ static inline int
579
+ __gthread_key_delete (__gthread_key_t key)
580
+ {
581
+ return __gthrw_pthread_key_delete (key);
582
+ }
583
+
584
+ static inline void *
585
+ __gthread_getspecific (__gthread_key_t key)
586
+ {
587
+ return __gthrw_pthread_getspecific (key);
588
+ }
589
+
590
+ static inline int
591
+ __gthread_setspecific (__gthread_key_t key, const void *ptr)
592
+ {
593
+ return __gthrw_pthread_setspecific (key, ptr);
594
+ }
595
+
596
+ static inline int
597
+ __gthread_mutex_lock (__gthread_mutex_t *mutex)
598
+ {
599
+ if (__gthread_active_p ())
600
+ return __gthrw_pthread_mutex_lock (mutex);
601
+ else
602
+ return 0;
603
+ }
604
+
605
+ static inline int
606
+ __gthread_mutex_trylock (__gthread_mutex_t *mutex)
607
+ {
608
+ if (__gthread_active_p ())
609
+ return __gthrw_pthread_mutex_trylock (mutex);
610
+ else
611
+ return 0;
612
+ }
613
+
614
+ static inline int
615
+ __gthread_mutex_unlock (__gthread_mutex_t *mutex)
616
+ {
617
+ if (__gthread_active_p ())
618
+ return __gthrw_pthread_mutex_unlock (mutex);
619
+ else
620
+ return 0;
621
+ }
622
+
623
+ #ifndef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
624
+ static inline int
625
+ __gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *mutex)
626
+ {
627
+ if (__gthread_active_p ())
628
+ {
629
+ pthread_mutexattr_t attr;
630
+ int r;
631
+
632
+ r = __gthrw_pthread_mutexattr_init (&attr);
633
+ if (!r)
634
+ r = __gthrw_pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
635
+ if (!r)
636
+ r = __gthrw_pthread_mutex_init (mutex, &attr);
637
+ if (!r)
638
+ r = __gthrw_pthread_mutexattr_destroy (&attr);
639
+ return r;
640
+ }
641
+ }
642
+ #endif
643
+
644
+ static inline int
645
+ __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex)
646
+ {
647
+ return __gthread_mutex_lock (mutex);
648
+ }
649
+
650
+ static inline int
651
+ __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex)
652
+ {
653
+ return __gthread_mutex_trylock (mutex);
654
+ }
655
+
656
+ static inline int
657
+ __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex)
658
+ {
659
+ return __gthread_mutex_unlock (mutex);
660
+ }
661
+
662
+ #endif /* _LIBOBJC */
663
+
664
+ #endif /* ! _GLIBCXX_GCC_GTHR_POSIX_H */