OSDN Git Service

2005-02-28 Andrew Pinski <pinskia@physics.uc.edu>
[pf3gnuchains/gcc-fork.git] / libobjc / thr-objc.c
1 /* GNU Objective C Runtime Thread Interface.
2    Copyright (C) 1999 Free Software Foundation, Inc.
3
4 This file is part of GCC.
5
6 GCC is free software; you can redistribute it and/or modify it under the
7 terms of the GNU General Public License as published by the Free Software
8 Foundation; either version 2, or (at your option) any later version.
9
10 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
13 details.
14
15 You should have received a copy of the GNU General Public License
16 along with GCC; see the file COPYING.  If not, write to
17 the Free Software Foundation, 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.  */
19
20 /* As a special exception, if you link this library with files compiled with
21    GCC to produce an executable, this does not cause the resulting executable
22    to be covered by the GNU General Public License. This exception does not
23    however invalidate any other reasons why the executable file might be
24    covered by the GNU General Public License.  */
25
26 #define _LIBOBJC
27 #include "config.h"
28 #include "tconfig.h"
29 #include "coretypes.h"
30 #include "tm.h"
31 #include "defaults.h"
32 #include <objc/thr.h>
33 #include "runtime.h"
34 #include <gthr.h>
35
36 /* Backend initialization functions */
37
38 /* Initialize the threads subsystem. */
39 int
40 __objc_init_thread_system(void)
41 {
42   return __gthread_objc_init_thread_system ();
43 }
44
45 /* Close the threads subsystem. */
46 int
47 __objc_close_thread_system(void)
48 {
49   return __gthread_objc_close_thread_system ();
50 }
51
52 /* Backend thread functions */
53
54 /* Create a new thread of execution. */
55 objc_thread_t
56 __objc_thread_detach(void (*func)(void *), void *arg)
57 {
58   return __gthread_objc_thread_detach (func, arg);
59 }
60
61 /* Set the current thread's priority. */
62 int
63 __objc_thread_set_priority(int priority)
64 {
65   return __gthread_objc_thread_set_priority (priority);
66 }
67
68 /* Return the current thread's priority. */
69 int
70 __objc_thread_get_priority(void)
71 {
72   return __gthread_objc_thread_get_priority ();
73 }
74
75 /* Yield our process time to another thread. */
76 void
77 __objc_thread_yield(void)
78 {
79   __gthread_objc_thread_yield ();
80 }
81
82 /* Terminate the current thread. */
83 int
84 __objc_thread_exit(void)
85 {
86   return __gthread_objc_thread_exit ();
87 }
88
89 /* Returns an integer value which uniquely describes a thread. */
90 objc_thread_t
91 __objc_thread_id(void)
92 {
93   return __gthread_objc_thread_id ();
94 }
95
96 /* Sets the thread's local storage pointer. */
97 int
98 __objc_thread_set_data(void *value)
99 {
100   return __gthread_objc_thread_set_data (value);
101 }
102
103 /* Returns the thread's local storage pointer. */
104 void *
105 __objc_thread_get_data(void)
106 {
107   return __gthread_objc_thread_get_data ();
108 }
109
110 /* Backend mutex functions */
111
112 /* Allocate a mutex. */
113 int
114 __objc_mutex_allocate(objc_mutex_t mutex)
115 {
116   return __gthread_objc_mutex_allocate (mutex);
117 }
118
119 /* Deallocate a mutex. */
120 int
121 __objc_mutex_deallocate(objc_mutex_t mutex)
122 {
123   return __gthread_objc_mutex_deallocate (mutex);
124 }
125
126 /* Grab a lock on a mutex. */
127 int
128 __objc_mutex_lock(objc_mutex_t mutex)
129 {
130   return __gthread_objc_mutex_lock (mutex);
131 }
132
133 /* Try to grab a lock on a mutex. */
134 int
135 __objc_mutex_trylock(objc_mutex_t mutex)
136 {
137   return __gthread_objc_mutex_trylock (mutex);
138 }
139
140 /* Unlock the mutex */
141 int
142 __objc_mutex_unlock(objc_mutex_t mutex)
143 {
144   return __gthread_objc_mutex_unlock (mutex);
145 }
146
147 /* Backend condition mutex functions */
148
149 /* Allocate a condition. */
150 int
151 __objc_condition_allocate(objc_condition_t condition)
152 {
153   return __gthread_objc_condition_allocate (condition);
154 }
155
156 /* Deallocate a condition. */
157 int
158 __objc_condition_deallocate(objc_condition_t condition)
159 {
160   return __gthread_objc_condition_deallocate (condition);
161 }
162
163 /* Wait on the condition */
164 int
165 __objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex)
166 {
167   return __gthread_objc_condition_wait (condition, mutex);
168 }
169
170 /* Wake up all threads waiting on this condition. */
171 int
172 __objc_condition_broadcast(objc_condition_t condition)
173 {
174   return __gthread_objc_condition_broadcast (condition);
175 }
176
177 /* Wake up one thread waiting on this condition. */
178 int
179 __objc_condition_signal(objc_condition_t condition)
180 {
181   return __gthread_objc_condition_signal (condition);
182 }
183
184 /* End of File */