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
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
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
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. */
47 /* Some implementations of <pthread.h> require this to be defined. */
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
66 #define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
67 #define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
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
80 # define __gthrw(name)
81 # define __gthrw_(name) name
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
)
96 __gthread_active_p (void)
102 __gthread_once (__gthread_once_t
*once
, void (*func
) (void))
104 if (__tpf_pthread_active ())
105 return __gthrw_(pthread_once
) (once
, func
);
111 __gthread_key_create (__gthread_key_t
*key
, void (*dtor
) (void *))
113 if (__tpf_pthread_active ())
114 return __gthrw_(pthread_key_create
) (key
, dtor
);
120 __gthread_key_delete (__gthread_key_t key
)
122 if (__tpf_pthread_active ())
123 return __gthrw_(pthread_key_delete
) (key
);
129 __gthread_getspecific (__gthread_key_t key
)
131 if (__tpf_pthread_active ())
132 return __gthrw_(pthread_getspecific
) (key
);
138 __gthread_setspecific (__gthread_key_t key
, const void *ptr
)
140 if (__tpf_pthread_active ())
141 return __gthrw_(pthread_setspecific
) (key
, ptr
);
147 __gthread_mutex_lock (__gthread_mutex_t
*mutex
)
149 if (__tpf_pthread_active ())
150 return __gthrw_(pthread_mutex_lock
) (mutex
);
156 __gthread_mutex_trylock (__gthread_mutex_t
*mutex
)
158 if (__tpf_pthread_active ())
159 return __gthrw_(pthread_mutex_trylock
) (mutex
);
165 __gthread_mutex_unlock (__gthread_mutex_t
*mutex
)
167 if (__tpf_pthread_active ())
168 return __gthrw_(pthread_mutex_unlock
) (mutex
);
174 __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t
*mutex
)
176 if (__tpf_pthread_active ())
177 return __gthread_mutex_lock (mutex
);
183 __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t
*mutex
)
185 if (__tpf_pthread_active ())
186 return __gthread_mutex_trylock (mutex
);
192 __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t
*mutex
)
194 if (__tpf_pthread_active ())
195 return __gthread_mutex_unlock (mutex
);
200 #endif /* ! _GLIBCXX_GCC_GTHR_TPF_H */