Fix indentation.
[official-gcc.git] / libobjc / thr-objc.c
blob5cc6433c621296450dc10c30747b3b2ede4bda59
1 /* GNU Objective C Runtime Thread Interface.
2 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2009
3 Free Software Foundation, Inc.
5 This file is part of GCC.
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.
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.
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.
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/>. */
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>
43 /* Backend initialization functions */
45 /* Initialize the threads subsystem. */
46 int
47 __objc_init_thread_system(void)
49 return __gthread_objc_init_thread_system ();
52 /* Close the threads subsystem. */
53 int
54 __objc_close_thread_system(void)
56 return __gthread_objc_close_thread_system ();
59 /* Backend thread functions */
61 /* Create a new thread of execution. */
62 objc_thread_t
63 __objc_thread_detach(void (*func)(void *), void *arg)
65 return __gthread_objc_thread_detach (func, arg);
68 /* Set the current thread's priority. */
69 int
70 __objc_thread_set_priority(int priority)
72 return __gthread_objc_thread_set_priority (priority);
75 /* Return the current thread's priority. */
76 int
77 __objc_thread_get_priority(void)
79 return __gthread_objc_thread_get_priority ();
82 /* Yield our process time to another thread. */
83 void
84 __objc_thread_yield(void)
86 __gthread_objc_thread_yield ();
89 /* Terminate the current thread. */
90 int
91 __objc_thread_exit(void)
93 return __gthread_objc_thread_exit ();
96 /* Returns an integer value which uniquely describes a thread. */
97 objc_thread_t
98 __objc_thread_id(void)
100 return __gthread_objc_thread_id ();
103 /* Sets the thread's local storage pointer. */
105 __objc_thread_set_data(void *value)
107 return __gthread_objc_thread_set_data (value);
110 /* Returns the thread's local storage pointer. */
111 void *
112 __objc_thread_get_data(void)
114 return __gthread_objc_thread_get_data ();
117 /* Backend mutex functions */
119 /* Allocate a mutex. */
121 __objc_mutex_allocate(objc_mutex_t mutex)
123 return __gthread_objc_mutex_allocate (mutex);
126 /* Deallocate a mutex. */
128 __objc_mutex_deallocate(objc_mutex_t mutex)
130 return __gthread_objc_mutex_deallocate (mutex);
133 /* Grab a lock on a mutex. */
135 __objc_mutex_lock(objc_mutex_t mutex)
137 return __gthread_objc_mutex_lock (mutex);
140 /* Try to grab a lock on a mutex. */
142 __objc_mutex_trylock(objc_mutex_t mutex)
144 return __gthread_objc_mutex_trylock (mutex);
147 /* Unlock the mutex */
149 __objc_mutex_unlock(objc_mutex_t mutex)
151 return __gthread_objc_mutex_unlock (mutex);
154 /* Backend condition mutex functions */
156 /* Allocate a condition. */
158 __objc_condition_allocate(objc_condition_t condition)
160 return __gthread_objc_condition_allocate (condition);
163 /* Deallocate a condition. */
165 __objc_condition_deallocate(objc_condition_t condition)
167 return __gthread_objc_condition_deallocate (condition);
170 /* Wait on the condition */
172 __objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex)
174 return __gthread_objc_condition_wait (condition, mutex);
177 /* Wake up all threads waiting on this condition. */
179 __objc_condition_broadcast(objc_condition_t condition)
181 return __gthread_objc_condition_broadcast (condition);
184 /* Wake up one thread waiting on this condition. */
186 __objc_condition_signal(objc_condition_t condition)
188 return __gthread_objc_condition_signal (condition);
191 /* End of File */