Fix mdoc(7)/man(7) mix up.
[netbsd-mini2440.git] / gnu / lib / libstdc++-v3_4 / arch / m68000 / gthr-tpf.h
blobd915b1e7369f0f69862fca1377ddd28fc8423e45
1 /* This file is automatically generated. DO NOT EDIT! */
2 /* Generated from: NetBSD: mknative-gcc,v 1.20 2006/06/09 15:30:52 skrll Exp */
3 /* Generated from: NetBSD: mknative.common,v 1.8 2006/05/26 19:17:21 mrg Exp */
5 /* Threads compatibility routines for libgcc2 and libobjc.
6 Compile this one with gcc.
7 Copyright (C) 2004, 2005 Free Software Foundation, Inc.
9 This file is part of GCC.
11 GCC is free software; you can redistribute it and/or modify it under
12 the terms of the GNU General Public License as published by the Free
13 Software Foundation; either version 2, or (at your option) any later
14 version.
16 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
17 WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 for more details.
21 You should have received a copy of the GNU General Public License
22 along with GCC; see the file COPYING. If not, write to the Free
23 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
24 02110-1301, USA. */
26 /* As a special exception, if you link this library with other files,
27 some of which are compiled with GCC, to produce an executable,
28 this library does not by itself cause the resulting executable
29 to be covered by the GNU General Public License.
30 This exception does not however invalidate any other reasons why
31 the executable file might be covered by the GNU General Public License. */
34 /* TPF needs its own version of gthr-*.h because TPF always links to
35 the thread library. However, for performance reasons we still do not
36 want to issue thread api calls unless a check is made to see that we
37 are running as a thread. */
39 #ifndef _GLIBCXX_GCC_GTHR_TPF_H
40 #define _GLIBCXX_GCC_GTHR_TPF_H
42 /* POSIX threads specific definitions.
43 Easy, since the interface is just one-to-one mapping. */
45 #define __GTHREADS 1
47 /* Some implementations of <pthread.h> require this to be defined. */
48 #ifndef _REENTRANT
49 #define _REENTRANT 1
50 #endif
52 #include <pthread.h>
53 #include <unistd.h>
55 typedef pthread_key_t __gthread_key_t;
56 typedef pthread_once_t __gthread_once_t;
57 typedef pthread_mutex_t __gthread_mutex_t;
58 typedef pthread_mutex_t __gthread_recursive_mutex_t;
60 #if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
61 #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER
62 #elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
63 #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
64 #endif
66 #define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
67 #define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
69 #define NOTATHREAD 00
70 #define ECBBASEPTR (unsigned long int) *(unsigned int *)0x00000514u
71 #define ECBPG2PTR ECBBASEPTR + 0x1000
72 #define CE2THRCPTR *((unsigned char *)(ECBPG2PTR + 16))
73 #define __tpf_pthread_active() (CE2THRCPTR != NOTATHREAD)
75 #if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK
76 # define __gthrw(name) \
77 extern __typeof(name) __gthrw_ ## name __attribute__ ((__weakref__(#name)));
78 # define __gthrw_(name) __gthrw_ ## name
79 #else
80 # define __gthrw(name)
81 # define __gthrw_(name) name
82 #endif
84 __gthrw(pthread_once)
85 __gthrw(pthread_key_create)
86 __gthrw(pthread_key_delete)
87 __gthrw(pthread_getspecific)
88 __gthrw(pthread_setspecific)
89 __gthrw(pthread_create)
91 __gthrw(pthread_mutex_lock)
92 __gthrw(pthread_mutex_trylock)
93 __gthrw(pthread_mutex_unlock)
95 static inline int
96 __gthread_active_p (void)
98 return 1;
101 static inline int
102 __gthread_once (__gthread_once_t *once, void (*func) (void))
104 if (__tpf_pthread_active ())
105 return __gthrw_(pthread_once) (once, func);
106 else
107 return -1;
110 static inline int
111 __gthread_key_create (__gthread_key_t *key, void (*dtor) (void *))
113 if (__tpf_pthread_active ())
114 return __gthrw_(pthread_key_create) (key, dtor);
115 else
116 return -1;
119 static inline int
120 __gthread_key_delete (__gthread_key_t key)
122 if (__tpf_pthread_active ())
123 return __gthrw_(pthread_key_delete) (key);
124 else
125 return -1;
128 static inline void *
129 __gthread_getspecific (__gthread_key_t key)
131 if (__tpf_pthread_active ())
132 return __gthrw_(pthread_getspecific) (key);
133 else
134 return NULL;
137 static inline int
138 __gthread_setspecific (__gthread_key_t key, const void *ptr)
140 if (__tpf_pthread_active ())
141 return __gthrw_(pthread_setspecific) (key, ptr);
142 else
143 return -1;
146 static inline int
147 __gthread_mutex_lock (__gthread_mutex_t *mutex)
149 if (__tpf_pthread_active ())
150 return __gthrw_(pthread_mutex_lock) (mutex);
151 else
152 return 0;
155 static inline int
156 __gthread_mutex_trylock (__gthread_mutex_t *mutex)
158 if (__tpf_pthread_active ())
159 return __gthrw_(pthread_mutex_trylock) (mutex);
160 else
161 return 0;
164 static inline int
165 __gthread_mutex_unlock (__gthread_mutex_t *mutex)
167 if (__tpf_pthread_active ())
168 return __gthrw_(pthread_mutex_unlock) (mutex);
169 else
170 return 0;
173 static inline int
174 __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex)
176 if (__tpf_pthread_active ())
177 return __gthread_mutex_lock (mutex);
178 else
179 return 0;
182 static inline int
183 __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex)
185 if (__tpf_pthread_active ())
186 return __gthread_mutex_trylock (mutex);
187 else
188 return 0;
191 static inline int
192 __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex)
194 if (__tpf_pthread_active ())
195 return __gthread_mutex_unlock (mutex);
196 else
197 return 0;
200 #endif /* ! _GLIBCXX_GCC_GTHR_TPF_H */