gccxml_gem 0.9.1-x86-darwin-9 → 0.9.2-x86-darwin-9
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +5 -1
- data/bin/gccxml +0 -0
- data/bin/gccxml_cc1plus +0 -0
- data/gccxml.rb +5 -5
- data/share/gccxml-0.9/GCC/3.2/bits/gthr-default.h +581 -0
- data/share/gccxml-0.9/GCC/3.4/bits/gthr-default.h +664 -0
- data/share/gccxml-0.9/GCC/4.3/gccxml_builtins.h +182 -0
- data/share/gccxml-0.9/IBM/8.0/adapt_headers.sh +34 -0
- data/share/gccxml-0.9/IBM/8.0/stdlib.h.patch +27 -0
- data/share/gccxml-0.9/IBM/8.0/xstring.patch +19 -0
- data/share/gccxml-0.9/IBM/README +8 -0
- data/share/gccxml-0.9/IBM/find_flags +51 -0
- data/share/gccxml-0.9/IBM/find_flags_common +48 -0
- data/share/gccxml-0.9/Intel/find_flags +1 -1
- data/share/gccxml-0.9/MIPSpro/find_flags +13 -80
- data/share/gccxml-0.9/MIPSpro/mipspro_defs.cxx +63 -0
- data/share/gccxml-0.9/Sun/5.8/{adaptation.patch → Cstd.patch} +96 -108
- data/share/gccxml-0.9/Sun/5.8/adapt_headers.sh +32 -0
- data/share/gccxml-0.9/Sun/5.8/std-5.10.patch +22 -0
- data/share/gccxml-0.9/Sun/README +4 -4
- data/share/gccxml-0.9/Sun/find_flags +20 -38
- data/share/gccxml-0.9/Sun/find_flags_common +42 -0
- data/share/gccxml-0.9/gccxml_config +1 -1
- data/share/gccxml-0.9/gccxml_identify_compiler.cc +13 -0
- data/share/man/man1/gccxml.1 +1 -1
- metadata +27 -37
- data/share/gccxml-0.9/GCC/find_flags +0 -105
- data/share/gccxml-0.9/Sun/adapt_headers.sh +0 -24
- data/share/gccxml-0.9/gccxml_find_flags +0 -93
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@ require 'rake/rdoctask'
|
|
3
3
|
require 'rake/gempackagetask'
|
4
4
|
|
5
5
|
PROJECT_NAME = "gccxml_gem"
|
6
|
-
GCCXML_VERSION = "0.9.
|
6
|
+
GCCXML_VERSION = "0.9.2"
|
7
7
|
RUBYFORGE_USERNAME = "jameskilton"
|
8
8
|
|
9
9
|
desc "Build gccxml for this system"
|
@@ -31,6 +31,10 @@ task :install do
|
|
31
31
|
|
32
32
|
sh "chmod a+x bin/*"
|
33
33
|
sh "chmod -R a+rx share/"
|
34
|
+
|
35
|
+
cd "bin" do
|
36
|
+
`cp gccxml_cc1plus.exe gccxml_cc1plus` if File.exists?("gccxml_cc1plus.exe")
|
37
|
+
end
|
34
38
|
end
|
35
39
|
|
36
40
|
desc "Clean up everything"
|
data/bin/gccxml
CHANGED
Binary file
|
data/bin/gccxml_cc1plus
CHANGED
Binary file
|
data/gccxml.rb
CHANGED
@@ -31,12 +31,12 @@ class GCCXML
|
|
31
31
|
|
32
32
|
private
|
33
33
|
|
34
|
+
def windows?
|
35
|
+
RUBY_PLATFORM =~ /(mswin|cygwin)/
|
36
|
+
end
|
37
|
+
|
34
38
|
def find_exe
|
35
|
-
ext =
|
36
|
-
".exe"
|
37
|
-
else
|
38
|
-
""
|
39
|
-
end
|
39
|
+
ext = windows? ? ".exe" : ""
|
40
40
|
|
41
41
|
path = File.expand_path(File.join(File.dirname(__FILE__), "bin", "gccxml#{ext}"))
|
42
42
|
path.chomp!
|
@@ -0,0 +1,581 @@
|
|
1
|
+
/* Threads compatibility routines for libgcc2 and libobjc. */
|
2
|
+
/* Compile this one with gcc. */
|
3
|
+
/* Copyright (C) 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
|
4
|
+
|
5
|
+
This file is part of GCC.
|
6
|
+
|
7
|
+
GCC is free software; you can redistribute it and/or modify it under
|
8
|
+
the terms of the GNU General Public License as published by the Free
|
9
|
+
Software Foundation; either version 2, or (at your option) any later
|
10
|
+
version.
|
11
|
+
|
12
|
+
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
13
|
+
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
14
|
+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
15
|
+
for more details.
|
16
|
+
|
17
|
+
You should have received a copy of the GNU General Public License
|
18
|
+
along with GCC; see the file COPYING. If not, write to the Free
|
19
|
+
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
20
|
+
02111-1307, USA. */
|
21
|
+
|
22
|
+
/* As a special exception, if you link this library with other files,
|
23
|
+
some of which are compiled with GCC, to produce an executable,
|
24
|
+
this library does not by itself cause the resulting executable
|
25
|
+
to be covered by the GNU General Public License.
|
26
|
+
This exception does not however invalidate any other reasons why
|
27
|
+
the executable file might be covered by the GNU General Public License. */
|
28
|
+
|
29
|
+
#ifndef _GLIBCPP_GCC_GTHR_POSIX_H
|
30
|
+
#define _GLIBCPP_GCC_GTHR_POSIX_H
|
31
|
+
|
32
|
+
/* POSIX threads specific definitions.
|
33
|
+
Easy, since the interface is just one-to-one mapping. */
|
34
|
+
|
35
|
+
#define __GTHREADS 1
|
36
|
+
|
37
|
+
#include <pthread.h>
|
38
|
+
|
39
|
+
typedef pthread_key_t __gthread_key_t;
|
40
|
+
typedef pthread_once_t __gthread_once_t;
|
41
|
+
typedef pthread_mutex_t __gthread_mutex_t;
|
42
|
+
|
43
|
+
#define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
|
44
|
+
#define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
|
45
|
+
|
46
|
+
#if _GLIBCPP_SUPPORTS_WEAK && _GLIBCPP_GTHREAD_USE_WEAK && defined __GNUC_RH_RELEASE__ && __GNUC__ == 3 && __GNUC_MINOR__ == 2 && __GNUC_PATCHLEVEL__ == 3 && __GNUC_RH_RELEASE__ > 53 && !defined __attribute__
|
47
|
+
# define __gthrw(name) \
|
48
|
+
extern __typeof(name) __gthrw_ ## name
|
49
|
+
|
50
|
+
__gthrw(pthread_once);
|
51
|
+
__gthrw(pthread_key_create);
|
52
|
+
__gthrw(pthread_key_delete);
|
53
|
+
__gthrw(pthread_getspecific);
|
54
|
+
__gthrw(pthread_setspecific);
|
55
|
+
__gthrw(pthread_create);
|
56
|
+
|
57
|
+
__gthrw(pthread_mutex_lock );
|
58
|
+
__gthrw(pthread_mutex_trylock );
|
59
|
+
__gthrw(pthread_mutex_unlock );
|
60
|
+
|
61
|
+
#ifdef _LIBOBJC
|
62
|
+
/* Objective C. */
|
63
|
+
__gthrw(pthread_cond_broadcast);
|
64
|
+
__gthrw(pthread_cond_destroy);
|
65
|
+
__gthrw(pthread_cond_init);
|
66
|
+
__gthrw(pthread_cond_signal);
|
67
|
+
__gthrw(pthread_cond_wait);
|
68
|
+
__gthrw(pthread_exit);
|
69
|
+
__gthrw(pthread_mutex_init);
|
70
|
+
__gthrw(pthread_mutex_destroy);
|
71
|
+
__gthrw(pthread_self);
|
72
|
+
__gthrw(sched_get_priority_max);
|
73
|
+
__gthrw(sched_get_priority_min);
|
74
|
+
__gthrw(sched_yield);
|
75
|
+
__gthrw(pthread_attr_destroy);
|
76
|
+
__gthrw(pthread_attr_init);
|
77
|
+
__gthrw(pthread_attr_setdetachstate);
|
78
|
+
__gthrw(pthread_getschedparam);
|
79
|
+
__gthrw(pthread_setschedparam);
|
80
|
+
#endif
|
81
|
+
#else
|
82
|
+
#if _GLIBCPP_SUPPORTS_WEAK && _GLIBCPP_GTHREAD_USE_WEAK
|
83
|
+
|
84
|
+
#pragma weak pthread_once
|
85
|
+
#pragma weak pthread_key_create
|
86
|
+
#pragma weak pthread_key_delete
|
87
|
+
#pragma weak pthread_getspecific
|
88
|
+
#pragma weak pthread_setspecific
|
89
|
+
#pragma weak pthread_create
|
90
|
+
|
91
|
+
#pragma weak pthread_mutex_lock
|
92
|
+
#pragma weak pthread_mutex_trylock
|
93
|
+
#pragma weak pthread_mutex_unlock
|
94
|
+
|
95
|
+
#ifdef _LIBOBJC
|
96
|
+
/* Objective C. */
|
97
|
+
#pragma weak pthread_cond_broadcast
|
98
|
+
#pragma weak pthread_cond_destroy
|
99
|
+
#pragma weak pthread_cond_init
|
100
|
+
#pragma weak pthread_cond_signal
|
101
|
+
#pragma weak pthread_cond_wait
|
102
|
+
#pragma weak pthread_exit
|
103
|
+
#pragma weak pthread_mutex_init
|
104
|
+
#pragma weak pthread_mutex_destroy
|
105
|
+
#pragma weak pthread_self
|
106
|
+
#pragma weak sched_get_priority_max
|
107
|
+
#pragma weak sched_get_priority_min
|
108
|
+
#pragma weak sched_yield
|
109
|
+
#pragma weak pthread_attr_destroy
|
110
|
+
#pragma weak pthread_attr_init
|
111
|
+
#pragma weak pthread_attr_setdetachstate
|
112
|
+
#pragma weak pthread_getschedparam
|
113
|
+
#pragma weak pthread_setschedparam
|
114
|
+
#endif
|
115
|
+
#endif
|
116
|
+
|
117
|
+
#define __gthrw_pthread_once pthread_once
|
118
|
+
#define __gthrw_pthread_key_create pthread_key_create
|
119
|
+
#define __gthrw_pthread_key_delete pthread_key_delete
|
120
|
+
#define __gthrw_pthread_getspecific pthread_getspecific
|
121
|
+
#define __gthrw_pthread_setspecific pthread_setspecific
|
122
|
+
#define __gthrw_pthread_create pthread_create
|
123
|
+
|
124
|
+
#define __gthrw_pthread_mutex_lock pthread_mutex_lock
|
125
|
+
#define __gthrw_pthread_mutex_trylock pthread_mutex_trylock
|
126
|
+
#define __gthrw_pthread_mutex_unlock pthread_mutex_unlock
|
127
|
+
|
128
|
+
#ifdef _LIBOBJC
|
129
|
+
/* Objective C. */
|
130
|
+
#define __gthrw_pthread_cond_broadcast pthread_cond_broadcast
|
131
|
+
#define __gthrw_pthread_cond_destroy pthread_cond_destroy
|
132
|
+
#define __gthrw_pthread_cond_init pthread_cond_init
|
133
|
+
#define __gthrw_pthread_cond_signal pthread_cond_signal
|
134
|
+
#define __gthrw_pthread_cond_wait pthread_cond_wait
|
135
|
+
#define __gthrw_pthread_exit pthread_exit
|
136
|
+
#define __gthrw_pthread_mutex_init pthread_mutex_init
|
137
|
+
#define __gthrw_pthread_mutex_destroy pthread_mutex_destroy
|
138
|
+
#define __gthrw_pthread_self pthread_self
|
139
|
+
#define __gthrw_sched_get_priority_max sched_get_priority_max
|
140
|
+
#define __gthrw_sched_get_priority_min sched_get_priority_min
|
141
|
+
#define __gthrw_sched_yield sched_yield
|
142
|
+
#define __gthrw_pthread_attr_destroy pthread_attr_destroy
|
143
|
+
#define __gthrw_pthread_attr_init pthread_attr_init
|
144
|
+
#define __gthrw_pthread_attr_setdetachstate pthread_attr_setdetachstate
|
145
|
+
#define __gthrw_pthread_getschedparam pthread_getschedparam
|
146
|
+
#define __gthrw_pthread_setschedparam pthread_setschedparam
|
147
|
+
#endif
|
148
|
+
#endif
|
149
|
+
|
150
|
+
#if _GLIBCPP_SUPPORTS_WEAK && _GLIBCPP_GTHREAD_USE_WEAK
|
151
|
+
|
152
|
+
static inline int
|
153
|
+
__gthread_active_p (void)
|
154
|
+
{
|
155
|
+
static void *const __gthread_active_ptr = (void *) &__gthrw_pthread_create;
|
156
|
+
return __gthread_active_ptr != 0;
|
157
|
+
}
|
158
|
+
|
159
|
+
#else /* not _GLIBCPP_SUPPORTS_WEAK */
|
160
|
+
|
161
|
+
static inline int
|
162
|
+
__gthread_active_p (void)
|
163
|
+
{
|
164
|
+
return 1;
|
165
|
+
}
|
166
|
+
|
167
|
+
#endif /* _GLIBCPP_SUPPORTS_WEAK */
|
168
|
+
|
169
|
+
#ifdef _LIBOBJC
|
170
|
+
|
171
|
+
/* This is the config.h file in libobjc/ */
|
172
|
+
#include <config.h>
|
173
|
+
|
174
|
+
#ifdef HAVE_SCHED_H
|
175
|
+
# include <sched.h>
|
176
|
+
#endif
|
177
|
+
|
178
|
+
/* Key structure for maintaining thread specific storage */
|
179
|
+
static pthread_key_t _objc_thread_storage;
|
180
|
+
static pthread_attr_t _objc_thread_attribs;
|
181
|
+
|
182
|
+
/* Thread local storage for a single thread */
|
183
|
+
static void *thread_local_storage = NULL;
|
184
|
+
|
185
|
+
/* Backend initialization functions */
|
186
|
+
|
187
|
+
/* Initialize the threads subsystem. */
|
188
|
+
static inline int
|
189
|
+
__gthread_objc_init_thread_system(void)
|
190
|
+
{
|
191
|
+
if (__gthread_active_p ())
|
192
|
+
{
|
193
|
+
/* Initialize the thread storage key */
|
194
|
+
if (__gthrw_pthread_key_create(&_objc_thread_storage, NULL) == 0)
|
195
|
+
{
|
196
|
+
/* The normal default detach state for threads is
|
197
|
+
* PTHREAD_CREATE_JOINABLE which causes threads to not die
|
198
|
+
* when you think they should. */
|
199
|
+
if (__gthrw_pthread_attr_init(&_objc_thread_attribs) == 0
|
200
|
+
&& __gthrw_pthread_attr_setdetachstate(&_objc_thread_attribs,
|
201
|
+
PTHREAD_CREATE_DETACHED) == 0)
|
202
|
+
return 0;
|
203
|
+
}
|
204
|
+
}
|
205
|
+
|
206
|
+
return -1;
|
207
|
+
}
|
208
|
+
|
209
|
+
/* Close the threads subsystem. */
|
210
|
+
static inline int
|
211
|
+
__gthread_objc_close_thread_system(void)
|
212
|
+
{
|
213
|
+
if (__gthread_active_p ()
|
214
|
+
&& __gthrw_pthread_key_delete(_objc_thread_storage) == 0
|
215
|
+
&& __gthrw_pthread_attr_destroy(&_objc_thread_attribs) == 0)
|
216
|
+
return 0;
|
217
|
+
|
218
|
+
return -1;
|
219
|
+
}
|
220
|
+
|
221
|
+
/* Backend thread functions */
|
222
|
+
|
223
|
+
/* Create a new thread of execution. */
|
224
|
+
static inline objc_thread_t
|
225
|
+
__gthread_objc_thread_detach(void (*func)(void *), void *arg)
|
226
|
+
{
|
227
|
+
objc_thread_t thread_id;
|
228
|
+
pthread_t new_thread_handle;
|
229
|
+
|
230
|
+
if (!__gthread_active_p ())
|
231
|
+
return NULL;
|
232
|
+
|
233
|
+
if ( !(__gthrw_pthread_create(&new_thread_handle, NULL, (void *)func, arg)) )
|
234
|
+
thread_id = (objc_thread_t) new_thread_handle;
|
235
|
+
else
|
236
|
+
thread_id = NULL;
|
237
|
+
|
238
|
+
return thread_id;
|
239
|
+
}
|
240
|
+
|
241
|
+
/* Set the current thread's priority. */
|
242
|
+
static inline int
|
243
|
+
__gthread_objc_thread_set_priority(int priority)
|
244
|
+
{
|
245
|
+
if (!__gthread_active_p())
|
246
|
+
return -1;
|
247
|
+
else {
|
248
|
+
pthread_t thread_id = __gthrw_pthread_self();
|
249
|
+
int policy;
|
250
|
+
struct sched_param params;
|
251
|
+
int priority_min, priority_max;
|
252
|
+
|
253
|
+
if (__gthrw_pthread_getschedparam(thread_id, &policy, ¶ms) == 0)
|
254
|
+
{
|
255
|
+
if ((priority_max = __gthrw_sched_get_priority_max(policy)) != 0)
|
256
|
+
return -1;
|
257
|
+
|
258
|
+
if ((priority_min = __gthrw_sched_get_priority_min(policy)) != 0)
|
259
|
+
return -1;
|
260
|
+
|
261
|
+
if (priority > priority_max)
|
262
|
+
priority = priority_max;
|
263
|
+
else if (priority < priority_min)
|
264
|
+
priority = priority_min;
|
265
|
+
params.sched_priority = priority;
|
266
|
+
|
267
|
+
/*
|
268
|
+
* The solaris 7 and several other man pages incorrectly state that
|
269
|
+
* this should be a pointer to policy but pthread.h is universally
|
270
|
+
* at odds with this.
|
271
|
+
*/
|
272
|
+
if (__gthrw_pthread_setschedparam(thread_id, policy, ¶ms) == 0)
|
273
|
+
return 0;
|
274
|
+
}
|
275
|
+
return -1;
|
276
|
+
}
|
277
|
+
}
|
278
|
+
|
279
|
+
/* Return the current thread's priority. */
|
280
|
+
static inline int
|
281
|
+
__gthread_objc_thread_get_priority(void)
|
282
|
+
{
|
283
|
+
if (__gthread_active_p ())
|
284
|
+
{
|
285
|
+
int policy;
|
286
|
+
struct sched_param params;
|
287
|
+
|
288
|
+
if (__gthrw_pthread_getschedparam(__gthrw_pthread_self(), &policy, ¶ms) == 0)
|
289
|
+
return params.sched_priority;
|
290
|
+
else
|
291
|
+
return -1;
|
292
|
+
}
|
293
|
+
else
|
294
|
+
return OBJC_THREAD_INTERACTIVE_PRIORITY;
|
295
|
+
}
|
296
|
+
|
297
|
+
/* Yield our process time to another thread. */
|
298
|
+
static inline void
|
299
|
+
__gthread_objc_thread_yield(void)
|
300
|
+
{
|
301
|
+
if (__gthread_active_p ())
|
302
|
+
__gthrw_sched_yield();
|
303
|
+
}
|
304
|
+
|
305
|
+
/* Terminate the current thread. */
|
306
|
+
static inline int
|
307
|
+
__gthread_objc_thread_exit(void)
|
308
|
+
{
|
309
|
+
if (__gthread_active_p ())
|
310
|
+
/* exit the thread */
|
311
|
+
__gthrw_pthread_exit(&__objc_thread_exit_status);
|
312
|
+
|
313
|
+
/* Failed if we reached here */
|
314
|
+
return -1;
|
315
|
+
}
|
316
|
+
|
317
|
+
/* Returns an integer value which uniquely describes a thread. */
|
318
|
+
static inline objc_thread_t
|
319
|
+
__gthread_objc_thread_id(void)
|
320
|
+
{
|
321
|
+
if (__gthread_active_p ())
|
322
|
+
return (objc_thread_t) __gthrw_pthread_self();
|
323
|
+
else
|
324
|
+
return (objc_thread_t) 1;
|
325
|
+
}
|
326
|
+
|
327
|
+
/* Sets the thread's local storage pointer. */
|
328
|
+
static inline int
|
329
|
+
__gthread_objc_thread_set_data(void *value)
|
330
|
+
{
|
331
|
+
if (__gthread_active_p ())
|
332
|
+
return __gthrw_pthread_setspecific(_objc_thread_storage, value);
|
333
|
+
else
|
334
|
+
{
|
335
|
+
thread_local_storage = value;
|
336
|
+
return 0;
|
337
|
+
}
|
338
|
+
}
|
339
|
+
|
340
|
+
/* Returns the thread's local storage pointer. */
|
341
|
+
static inline void *
|
342
|
+
__gthread_objc_thread_get_data(void)
|
343
|
+
{
|
344
|
+
if (__gthread_active_p ())
|
345
|
+
return __gthrw_pthread_getspecific(_objc_thread_storage);
|
346
|
+
else
|
347
|
+
return thread_local_storage;
|
348
|
+
}
|
349
|
+
|
350
|
+
/* Backend mutex functions */
|
351
|
+
|
352
|
+
/* Allocate a mutex. */
|
353
|
+
static inline int
|
354
|
+
__gthread_objc_mutex_allocate(objc_mutex_t mutex)
|
355
|
+
{
|
356
|
+
if (__gthread_active_p ())
|
357
|
+
{
|
358
|
+
mutex->backend = objc_malloc(sizeof(pthread_mutex_t));
|
359
|
+
|
360
|
+
if (__gthrw_pthread_mutex_init((pthread_mutex_t *)mutex->backend, NULL))
|
361
|
+
{
|
362
|
+
objc_free(mutex->backend);
|
363
|
+
mutex->backend = NULL;
|
364
|
+
return -1;
|
365
|
+
}
|
366
|
+
}
|
367
|
+
|
368
|
+
return 0;
|
369
|
+
}
|
370
|
+
|
371
|
+
/* Deallocate a mutex. */
|
372
|
+
static inline int
|
373
|
+
__gthread_objc_mutex_deallocate(objc_mutex_t mutex)
|
374
|
+
{
|
375
|
+
if (__gthread_active_p ())
|
376
|
+
{
|
377
|
+
int count;
|
378
|
+
|
379
|
+
/*
|
380
|
+
* Posix Threads specifically require that the thread be unlocked
|
381
|
+
* for __gthrw_pthread_mutex_destroy to work.
|
382
|
+
*/
|
383
|
+
|
384
|
+
do
|
385
|
+
{
|
386
|
+
count = __gthrw_pthread_mutex_unlock((pthread_mutex_t *)mutex->backend);
|
387
|
+
if (count < 0)
|
388
|
+
return -1;
|
389
|
+
}
|
390
|
+
while (count);
|
391
|
+
|
392
|
+
if (__gthrw_pthread_mutex_destroy((pthread_mutex_t *)mutex->backend))
|
393
|
+
return -1;
|
394
|
+
|
395
|
+
objc_free(mutex->backend);
|
396
|
+
mutex->backend = NULL;
|
397
|
+
}
|
398
|
+
return 0;
|
399
|
+
}
|
400
|
+
|
401
|
+
/* Grab a lock on a mutex. */
|
402
|
+
static inline int
|
403
|
+
__gthread_objc_mutex_lock(objc_mutex_t mutex)
|
404
|
+
{
|
405
|
+
if (__gthread_active_p ()
|
406
|
+
&& __gthrw_pthread_mutex_lock((pthread_mutex_t *)mutex->backend) != 0)
|
407
|
+
{
|
408
|
+
return -1;
|
409
|
+
}
|
410
|
+
|
411
|
+
return 0;
|
412
|
+
}
|
413
|
+
|
414
|
+
/* Try to grab a lock on a mutex. */
|
415
|
+
static inline int
|
416
|
+
__gthread_objc_mutex_trylock(objc_mutex_t mutex)
|
417
|
+
{
|
418
|
+
if (__gthread_active_p ()
|
419
|
+
&& __gthrw_pthread_mutex_trylock((pthread_mutex_t *)mutex->backend) != 0)
|
420
|
+
{
|
421
|
+
return -1;
|
422
|
+
}
|
423
|
+
|
424
|
+
return 0;
|
425
|
+
}
|
426
|
+
|
427
|
+
/* Unlock the mutex */
|
428
|
+
static inline int
|
429
|
+
__gthread_objc_mutex_unlock(objc_mutex_t mutex)
|
430
|
+
{
|
431
|
+
if (__gthread_active_p ()
|
432
|
+
&& __gthrw_pthread_mutex_unlock((pthread_mutex_t *)mutex->backend) != 0)
|
433
|
+
{
|
434
|
+
return -1;
|
435
|
+
}
|
436
|
+
|
437
|
+
return 0;
|
438
|
+
}
|
439
|
+
|
440
|
+
/* Backend condition mutex functions */
|
441
|
+
|
442
|
+
/* Allocate a condition. */
|
443
|
+
static inline int
|
444
|
+
__gthread_objc_condition_allocate(objc_condition_t condition)
|
445
|
+
{
|
446
|
+
if (__gthread_active_p ())
|
447
|
+
{
|
448
|
+
condition->backend = objc_malloc(sizeof(pthread_cond_t));
|
449
|
+
|
450
|
+
if (__gthrw_pthread_cond_init((pthread_cond_t *)condition->backend, NULL))
|
451
|
+
{
|
452
|
+
objc_free(condition->backend);
|
453
|
+
condition->backend = NULL;
|
454
|
+
return -1;
|
455
|
+
}
|
456
|
+
}
|
457
|
+
|
458
|
+
return 0;
|
459
|
+
}
|
460
|
+
|
461
|
+
/* Deallocate a condition. */
|
462
|
+
static inline int
|
463
|
+
__gthread_objc_condition_deallocate(objc_condition_t condition)
|
464
|
+
{
|
465
|
+
if (__gthread_active_p ())
|
466
|
+
{
|
467
|
+
if (__gthrw_pthread_cond_destroy((pthread_cond_t *)condition->backend))
|
468
|
+
return -1;
|
469
|
+
|
470
|
+
objc_free(condition->backend);
|
471
|
+
condition->backend = NULL;
|
472
|
+
}
|
473
|
+
return 0;
|
474
|
+
}
|
475
|
+
|
476
|
+
/* Wait on the condition */
|
477
|
+
static inline int
|
478
|
+
__gthread_objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex)
|
479
|
+
{
|
480
|
+
if (__gthread_active_p ())
|
481
|
+
return __gthrw_pthread_cond_wait((pthread_cond_t *)condition->backend,
|
482
|
+
(pthread_mutex_t *)mutex->backend);
|
483
|
+
else
|
484
|
+
return 0;
|
485
|
+
}
|
486
|
+
|
487
|
+
/* Wake up all threads waiting on this condition. */
|
488
|
+
static inline int
|
489
|
+
__gthread_objc_condition_broadcast(objc_condition_t condition)
|
490
|
+
{
|
491
|
+
if (__gthread_active_p ())
|
492
|
+
return __gthrw_pthread_cond_broadcast((pthread_cond_t *)condition->backend);
|
493
|
+
else
|
494
|
+
return 0;
|
495
|
+
}
|
496
|
+
|
497
|
+
/* Wake up one thread waiting on this condition. */
|
498
|
+
static inline int
|
499
|
+
__gthread_objc_condition_signal(objc_condition_t condition)
|
500
|
+
{
|
501
|
+
if (__gthread_active_p ())
|
502
|
+
return __gthrw_pthread_cond_signal((pthread_cond_t *)condition->backend);
|
503
|
+
else
|
504
|
+
return 0;
|
505
|
+
}
|
506
|
+
|
507
|
+
#else /* _LIBOBJC */
|
508
|
+
|
509
|
+
static inline int
|
510
|
+
__gthread_once (__gthread_once_t *once, void (*func) (void))
|
511
|
+
{
|
512
|
+
if (__gthread_active_p ())
|
513
|
+
return __gthrw_pthread_once (once, func);
|
514
|
+
else
|
515
|
+
return -1;
|
516
|
+
}
|
517
|
+
|
518
|
+
static inline int
|
519
|
+
__gthread_key_create (__gthread_key_t *key, void (*dtor) (void *))
|
520
|
+
{
|
521
|
+
return __gthrw_pthread_key_create (key, dtor);
|
522
|
+
}
|
523
|
+
|
524
|
+
static inline int
|
525
|
+
__gthread_key_dtor (__gthread_key_t key, void *ptr)
|
526
|
+
{
|
527
|
+
/* Just reset the key value to zero. */
|
528
|
+
if (ptr)
|
529
|
+
return __gthrw_pthread_setspecific (key, 0);
|
530
|
+
else
|
531
|
+
return 0;
|
532
|
+
}
|
533
|
+
|
534
|
+
static inline int
|
535
|
+
__gthread_key_delete (__gthread_key_t key)
|
536
|
+
{
|
537
|
+
return __gthrw_pthread_key_delete (key);
|
538
|
+
}
|
539
|
+
|
540
|
+
static inline void *
|
541
|
+
__gthread_getspecific (__gthread_key_t key)
|
542
|
+
{
|
543
|
+
return __gthrw_pthread_getspecific (key);
|
544
|
+
}
|
545
|
+
|
546
|
+
static inline int
|
547
|
+
__gthread_setspecific (__gthread_key_t key, const void *ptr)
|
548
|
+
{
|
549
|
+
return __gthrw_pthread_setspecific (key, ptr);
|
550
|
+
}
|
551
|
+
|
552
|
+
static inline int
|
553
|
+
__gthread_mutex_lock (__gthread_mutex_t *mutex)
|
554
|
+
{
|
555
|
+
if (__gthread_active_p ())
|
556
|
+
return __gthrw_pthread_mutex_lock (mutex);
|
557
|
+
else
|
558
|
+
return 0;
|
559
|
+
}
|
560
|
+
|
561
|
+
static inline int
|
562
|
+
__gthread_mutex_trylock (__gthread_mutex_t *mutex)
|
563
|
+
{
|
564
|
+
if (__gthread_active_p ())
|
565
|
+
return __gthrw_pthread_mutex_trylock (mutex);
|
566
|
+
else
|
567
|
+
return 0;
|
568
|
+
}
|
569
|
+
|
570
|
+
static inline int
|
571
|
+
__gthread_mutex_unlock (__gthread_mutex_t *mutex)
|
572
|
+
{
|
573
|
+
if (__gthread_active_p ())
|
574
|
+
return __gthrw_pthread_mutex_unlock (mutex);
|
575
|
+
else
|
576
|
+
return 0;
|
577
|
+
}
|
578
|
+
|
579
|
+
#endif /* _LIBOBJC */
|
580
|
+
|
581
|
+
#endif /* ! _GLIBCPP_GCC_GTHR_POSIX_H */
|