OSDN Git Service

* Makefile.in (local-distclean): Remove leftover built files.
[pf3gnuchains/gcc-fork.git] / gcc / gthr-single.h
1 /* Threads compatibility routines for libgcc2 and libobjc.  */
2 /* Compile this one with gcc.  */
3 /* Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc.
4
5 This file is part of GNU CC.
6
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 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 __gthr_single_h
30 #define __gthr_single_h
31
32 /* Just provide compatibility for mutex handling. */
33
34 typedef int __gthread_mutex_t;
35
36 #define __GTHREAD_MUTEX_INIT 0
37
38 #ifdef _LIBOBJC
39
40 /* Thread local storage for a single thread */
41 static void *thread_local_storage = NULL;
42
43 /* Backend initialization functions */
44
45 /* Initialize the threads subsystem. */
46 static inline int
47 __gthread_objc_init_thread_system(void)
48 {
49   /* No thread support available */
50   return -1;
51 }
52
53 /* Close the threads subsystem. */
54 static inline int
55 __gthread_objc_close_thread_system(void)
56 {
57   /* No thread support available */
58   return -1;
59 }
60
61 /* Backend thread functions */
62
63 /* Create a new thread of execution. */
64 static inline objc_thread_t
65 __gthread_objc_thread_detach(void (*func)(void *arg), void *arg)
66 {
67   /* No thread support available */
68   return NULL;
69 }
70
71 /* Set the current thread's priority. */
72 static inline int
73 __gthread_objc_thread_set_priority(int priority)
74 {
75   /* No thread support available */
76   return -1;
77 }
78
79 /* Return the current thread's priority. */
80 static inline int
81 __gthread_objc_thread_get_priority(void)
82 {
83   return OBJC_THREAD_INTERACTIVE_PRIORITY;
84 }
85
86 /* Yield our process time to another thread. */
87 static inline void
88 __gthread_objc_thread_yield(void)
89 {
90   return;
91 }
92
93 /* Terminate the current thread. */
94 static inline int
95 __gthread_objc_thread_exit(void)
96 {
97   /* No thread support available */
98   /* Should we really exit the program */
99   /* exit(&__objc_thread_exit_status); */
100   return -1;
101 }
102
103 /* Returns an integer value which uniquely describes a thread. */
104 static inline objc_thread_t
105 __gthread_objc_thread_id(void)
106 {
107   /* No thread support, use 1. */
108   return (objc_thread_t)1;
109 }
110
111 /* Sets the thread's local storage pointer. */
112 static inline int
113 __gthread_objc_thread_set_data(void *value)
114 {
115   thread_local_storage = value;
116   return 0;
117 }
118
119 /* Returns the thread's local storage pointer. */
120 static inline void *
121 __gthread_objc_thread_get_data(void)
122 {
123   return thread_local_storage;
124 }
125
126 /* Backend mutex functions */
127
128 /* Allocate a mutex. */
129 static inline int
130 __gthread_objc_mutex_allocate(objc_mutex_t mutex)
131 {
132   return 0;
133 }
134
135 /* Deallocate a mutex. */
136 static inline int
137 __gthread_objc_mutex_deallocate(objc_mutex_t mutex)
138 {
139   return 0;
140 }
141
142 /* Grab a lock on a mutex. */
143 static inline int
144 __gthread_objc_mutex_lock(objc_mutex_t mutex)
145 {
146   /* There can only be one thread, so we always get the lock */
147   return 0;
148 }
149
150 /* Try to grab a lock on a mutex. */
151 static inline int
152 __gthread_objc_mutex_trylock(objc_mutex_t mutex)
153 {
154   /* There can only be one thread, so we always get the lock */
155   return 0;
156 }
157
158 /* Unlock the mutex */
159 static inline int
160 __gthread_objc_mutex_unlock(objc_mutex_t mutex)
161 {
162   return 0;
163 }
164
165 /* Backend condition mutex functions */
166
167 /* Allocate a condition. */
168 static inline int
169 __gthread_objc_condition_allocate(objc_condition_t condition)
170 {
171   return 0;
172 }
173
174 /* Deallocate a condition. */
175 static inline int
176 __gthread_objc_condition_deallocate(objc_condition_t condition)
177 {
178   return 0;
179 }
180
181 /* Wait on the condition */
182 static inline int
183 __gthread_objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex)
184 {
185   return 0;
186 }
187
188 /* Wake up all threads waiting on this condition. */
189 static inline int
190 __gthread_objc_condition_broadcast(objc_condition_t condition)
191 {
192   return 0;
193 }
194
195 /* Wake up one thread waiting on this condition. */
196 static inline int
197 __gthread_objc_condition_signal(objc_condition_t condition)
198 {
199   return 0;
200 }
201
202 #else /* _LIBOBJC */
203
204 static inline int
205 __gthread_active_p (void)
206 {
207   return 0;
208 }
209
210 static inline int
211 __gthread_mutex_lock (__gthread_mutex_t *mutex __attribute__ ((__unused__)))
212 {
213   return 0;
214 }
215
216 static inline int
217 __gthread_mutex_trylock (__gthread_mutex_t *mutex __attribute__ ((__unused__)))
218 {
219   return 0;
220 }
221
222 static inline int
223 __gthread_mutex_unlock (__gthread_mutex_t *mutex __attribute__ ((__unused__)))
224 {
225   return 0;
226 }
227
228 #endif /* _LIBOBJC */
229
230 #endif /* not __gthr_single_h */