OSDN Git Service

* configure.ac: Determine Sun ld version numbers.
[pf3gnuchains/gcc-fork.git] / libobjc / thr-objc.c
1 /* GNU Objective C Runtime Thread Interface.
2    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2009
3    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 the
8 terms of the GNU General Public License as published by the Free Software
9 Foundation; either version 3, or (at your option) any later version.
10
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
14 details.
15
16 Under Section 7 of GPL version 3, you are granted additional
17 permissions described in the GCC Runtime Library Exception, version
18 3.1, as published by the Free Software Foundation.
19
20 You should have received a copy of the GNU General Public License and
21 a copy of the GCC Runtime Library Exception along with this program;
22 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23 <http://www.gnu.org/licenses/>.  */
24
25
26 #define _LIBOBJC
27 /* The line below is needed for declarations of functions such as
28    pthread_mutexattr_settype, without which gthr-posix.h may fail to
29    compile within libobjc.  Unfortunately, this breaks compilation on
30    Tru64 UNIX V4.0F, so disable it there.  */
31 #ifndef __osf__
32 #define _XOPEN_SOURCE 500
33 #endif
34 #include "config.h"
35 #include "tconfig.h"
36 #include "coretypes.h"
37 #include "tm.h"
38 #include "defaults.h"
39 #include "objc/thr.h"
40 #include "objc/runtime.h"
41 #include <gthr.h>
42
43 /* Backend initialization functions */
44
45 /* Initialize the threads subsystem. */
46 int
47 __objc_init_thread_system(void)
48 {
49   return __gthread_objc_init_thread_system ();
50 }
51
52 /* Close the threads subsystem. */
53 int
54 __objc_close_thread_system(void)
55 {
56   return __gthread_objc_close_thread_system ();
57 }
58
59 /* Backend thread functions */
60
61 /* Create a new thread of execution. */
62 objc_thread_t
63 __objc_thread_detach(void (*func)(void *), void *arg)
64 {
65   return __gthread_objc_thread_detach (func, arg);
66 }
67
68 /* Set the current thread's priority. */
69 int
70 __objc_thread_set_priority(int priority)
71 {
72   return __gthread_objc_thread_set_priority (priority);
73 }
74
75 /* Return the current thread's priority. */
76 int
77 __objc_thread_get_priority(void)
78 {
79   return __gthread_objc_thread_get_priority ();
80 }
81
82 /* Yield our process time to another thread. */
83 void
84 __objc_thread_yield(void)
85 {
86   __gthread_objc_thread_yield ();
87 }
88
89 /* Terminate the current thread. */
90 int
91 __objc_thread_exit(void)
92 {
93   return __gthread_objc_thread_exit ();
94 }
95
96 /* Returns an integer value which uniquely describes a thread. */
97 objc_thread_t
98 __objc_thread_id(void)
99 {
100   return __gthread_objc_thread_id ();
101 }
102
103 /* Sets the thread's local storage pointer. */
104 int
105 __objc_thread_set_data(void *value)
106 {
107   return __gthread_objc_thread_set_data (value);
108 }
109
110 /* Returns the thread's local storage pointer. */
111 void *
112 __objc_thread_get_data(void)
113 {
114   return __gthread_objc_thread_get_data ();
115 }
116
117 /* Backend mutex functions */
118
119 /* Allocate a mutex. */
120 int
121 __objc_mutex_allocate(objc_mutex_t mutex)
122 {
123   return __gthread_objc_mutex_allocate (mutex);
124 }
125
126 /* Deallocate a mutex. */
127 int
128 __objc_mutex_deallocate(objc_mutex_t mutex)
129 {
130   return __gthread_objc_mutex_deallocate (mutex);
131 }
132
133 /* Grab a lock on a mutex. */
134 int
135 __objc_mutex_lock(objc_mutex_t mutex)
136 {
137   return __gthread_objc_mutex_lock (mutex);
138 }
139
140 /* Try to grab a lock on a mutex. */
141 int
142 __objc_mutex_trylock(objc_mutex_t mutex)
143 {
144   return __gthread_objc_mutex_trylock (mutex);
145 }
146
147 /* Unlock the mutex */
148 int
149 __objc_mutex_unlock(objc_mutex_t mutex)
150 {
151   return __gthread_objc_mutex_unlock (mutex);
152 }
153
154 /* Backend condition mutex functions */
155
156 /* Allocate a condition. */
157 int
158 __objc_condition_allocate(objc_condition_t condition)
159 {
160   return __gthread_objc_condition_allocate (condition);
161 }
162
163 /* Deallocate a condition. */
164 int
165 __objc_condition_deallocate(objc_condition_t condition)
166 {
167   return __gthread_objc_condition_deallocate (condition);
168 }
169
170 /* Wait on the condition */
171 int
172 __objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex)
173 {
174   return __gthread_objc_condition_wait (condition, mutex);
175 }
176
177 /* Wake up all threads waiting on this condition. */
178 int
179 __objc_condition_broadcast(objc_condition_t condition)
180 {
181   return __gthread_objc_condition_broadcast (condition);
182 }
183
184 /* Wake up one thread waiting on this condition. */
185 int
186 __objc_condition_signal(objc_condition_t condition)
187 {
188   return __gthread_objc_condition_signal (condition);
189 }
190
191 /* End of File */