xref: /minix3/external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc/gthr.h (revision 18a5822eff3a5bdeb6301a60d7d6269594c7ce35)
1*18a5822eSThomas Veerman /* This file is automatically generated.  DO NOT EDIT! */
2*18a5822eSThomas Veerman /* Generated from: 	NetBSD: mknative-gcc,v 1.55 2011/06/30 07:16:59 mrg Exp  */
3*18a5822eSThomas Veerman /* Generated from: NetBSD: mknative.common,v 1.9 2007/02/05 18:26:01 apb Exp  */
4*18a5822eSThomas Veerman 
5*18a5822eSThomas Veerman /* Threads compatibility routines for libgcc2.  */
6*18a5822eSThomas Veerman /* Compile this one with gcc.  */
7*18a5822eSThomas Veerman /* Copyright (C) 1997, 1998, 2004, 2008, 2009 Free Software Foundation, Inc.
8*18a5822eSThomas Veerman 
9*18a5822eSThomas Veerman This file is part of GCC.
10*18a5822eSThomas Veerman 
11*18a5822eSThomas Veerman GCC is free software; you can redistribute it and/or modify it under
12*18a5822eSThomas Veerman the terms of the GNU General Public License as published by the Free
13*18a5822eSThomas Veerman Software Foundation; either version 3, or (at your option) any later
14*18a5822eSThomas Veerman version.
15*18a5822eSThomas Veerman 
16*18a5822eSThomas Veerman GCC is distributed in the hope that it will be useful, but WITHOUT ANY
17*18a5822eSThomas Veerman WARRANTY; without even the implied warranty of MERCHANTABILITY or
18*18a5822eSThomas Veerman FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19*18a5822eSThomas Veerman for more details.
20*18a5822eSThomas Veerman 
21*18a5822eSThomas Veerman Under Section 7 of GPL version 3, you are granted additional
22*18a5822eSThomas Veerman permissions described in the GCC Runtime Library Exception, version
23*18a5822eSThomas Veerman 3.1, as published by the Free Software Foundation.
24*18a5822eSThomas Veerman 
25*18a5822eSThomas Veerman You should have received a copy of the GNU General Public License and
26*18a5822eSThomas Veerman a copy of the GCC Runtime Library Exception along with this program;
27*18a5822eSThomas Veerman see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
28*18a5822eSThomas Veerman <http://www.gnu.org/licenses/>.  */
29*18a5822eSThomas Veerman 
30*18a5822eSThomas Veerman #ifndef _GLIBCXX_GCC_GTHR_H
31*18a5822eSThomas Veerman #define _GLIBCXX_GCC_GTHR_H
32*18a5822eSThomas Veerman 
33*18a5822eSThomas Veerman #ifndef _GLIBCXX_HIDE_EXPORTS
34*18a5822eSThomas Veerman #pragma GCC visibility push(default)
35*18a5822eSThomas Veerman #endif
36*18a5822eSThomas Veerman 
37*18a5822eSThomas Veerman /* If this file is compiled with threads support, it must
38*18a5822eSThomas Veerman        #define __GTHREADS 1
39*18a5822eSThomas Veerman    to indicate that threads support is present.  Also it has define
40*18a5822eSThomas Veerman    function
41*18a5822eSThomas Veerman      int __gthread_active_p ()
42*18a5822eSThomas Veerman    that returns 1 if thread system is active, 0 if not.
43*18a5822eSThomas Veerman 
44*18a5822eSThomas Veerman    The threads interface must define the following types:
45*18a5822eSThomas Veerman      __gthread_key_t
46*18a5822eSThomas Veerman      __gthread_once_t
47*18a5822eSThomas Veerman      __gthread_mutex_t
48*18a5822eSThomas Veerman      __gthread_recursive_mutex_t
49*18a5822eSThomas Veerman 
50*18a5822eSThomas Veerman    The threads interface must define the following macros:
51*18a5822eSThomas Veerman 
52*18a5822eSThomas Veerman      __GTHREAD_ONCE_INIT
53*18a5822eSThomas Veerman      		to initialize __gthread_once_t
54*18a5822eSThomas Veerman      __GTHREAD_MUTEX_INIT
55*18a5822eSThomas Veerman      		to initialize __gthread_mutex_t to get a fast
56*18a5822eSThomas Veerman 		non-recursive mutex.
57*18a5822eSThomas Veerman      __GTHREAD_MUTEX_INIT_FUNCTION
58*18a5822eSThomas Veerman      		some systems can't initialize a mutex without a
59*18a5822eSThomas Veerman 		function call.  On such systems, define this to a
60*18a5822eSThomas Veerman 		function which looks like this:
61*18a5822eSThomas Veerman 		  void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *)
62*18a5822eSThomas Veerman 		Don't define __GTHREAD_MUTEX_INIT in this case
63*18a5822eSThomas Veerman      __GTHREAD_RECURSIVE_MUTEX_INIT
64*18a5822eSThomas Veerman      __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
65*18a5822eSThomas Veerman      		as above, but for a recursive mutex.
66*18a5822eSThomas Veerman 
67*18a5822eSThomas Veerman    The threads interface must define the following static functions:
68*18a5822eSThomas Veerman 
69*18a5822eSThomas Veerman      int __gthread_once (__gthread_once_t *once, void (*func) ())
70*18a5822eSThomas Veerman 
71*18a5822eSThomas Veerman      int __gthread_key_create (__gthread_key_t *keyp, void (*dtor) (void *))
72*18a5822eSThomas Veerman      int __gthread_key_delete (__gthread_key_t key)
73*18a5822eSThomas Veerman 
74*18a5822eSThomas Veerman      void *__gthread_getspecific (__gthread_key_t key)
75*18a5822eSThomas Veerman      int __gthread_setspecific (__gthread_key_t key, const void *ptr)
76*18a5822eSThomas Veerman 
77*18a5822eSThomas Veerman      int __gthread_mutex_destroy (__gthread_mutex_t *mutex);
78*18a5822eSThomas Veerman 
79*18a5822eSThomas Veerman      int __gthread_mutex_lock (__gthread_mutex_t *mutex);
80*18a5822eSThomas Veerman      int __gthread_mutex_trylock (__gthread_mutex_t *mutex);
81*18a5822eSThomas Veerman      int __gthread_mutex_unlock (__gthread_mutex_t *mutex);
82*18a5822eSThomas Veerman 
83*18a5822eSThomas Veerman      int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex);
84*18a5822eSThomas Veerman      int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex);
85*18a5822eSThomas Veerman      int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex);
86*18a5822eSThomas Veerman 
87*18a5822eSThomas Veerman    The following are supported in POSIX threads only. They are required to
88*18a5822eSThomas Veerman    fix a deadlock in static initialization inside libsupc++. The header file
89*18a5822eSThomas Veerman    gthr-posix.h defines a symbol __GTHREAD_HAS_COND to signify that these extra
90*18a5822eSThomas Veerman    features are supported.
91*18a5822eSThomas Veerman 
92*18a5822eSThomas Veerman    Types:
93*18a5822eSThomas Veerman      __gthread_cond_t
94*18a5822eSThomas Veerman 
95*18a5822eSThomas Veerman    Macros:
96*18a5822eSThomas Veerman      __GTHREAD_COND_INIT
97*18a5822eSThomas Veerman      __GTHREAD_COND_INIT_FUNCTION
98*18a5822eSThomas Veerman 
99*18a5822eSThomas Veerman    Interface:
100*18a5822eSThomas Veerman      int __gthread_cond_broadcast (__gthread_cond_t *cond);
101*18a5822eSThomas Veerman      int __gthread_cond_wait (__gthread_cond_t *cond, __gthread_mutex_t *mutex);
102*18a5822eSThomas Veerman      int __gthread_cond_wait_recursive (__gthread_cond_t *cond,
103*18a5822eSThomas Veerman 					__gthread_recursive_mutex_t *mutex);
104*18a5822eSThomas Veerman 
105*18a5822eSThomas Veerman    All functions returning int should return zero on success or the error
106*18a5822eSThomas Veerman    number.  If the operation is not supported, -1 is returned.
107*18a5822eSThomas Veerman 
108*18a5822eSThomas Veerman    If the following are also defined, you should
109*18a5822eSThomas Veerman      #define __GTHREADS_CXX0X 1
110*18a5822eSThomas Veerman    to enable the c++0x thread library.
111*18a5822eSThomas Veerman 
112*18a5822eSThomas Veerman    Types:
113*18a5822eSThomas Veerman      __gthread_t
114*18a5822eSThomas Veerman      __gthread_time_t
115*18a5822eSThomas Veerman 
116*18a5822eSThomas Veerman    Interface:
117*18a5822eSThomas Veerman      int __gthread_create (__gthread_t *thread, void *(*func) (void*),
118*18a5822eSThomas Veerman                            void *args);
119*18a5822eSThomas Veerman      int __gthread_join (__gthread_t thread, void **value_ptr);
120*18a5822eSThomas Veerman      int __gthread_detach (__gthread_t thread);
121*18a5822eSThomas Veerman      int __gthread_equal (__gthread_t t1, __gthread_t t2);
122*18a5822eSThomas Veerman      __gthread_t __gthread_self (void);
123*18a5822eSThomas Veerman      int __gthread_yield (void);
124*18a5822eSThomas Veerman 
125*18a5822eSThomas Veerman      int __gthread_mutex_timedlock (__gthread_mutex_t *m,
126*18a5822eSThomas Veerman                                     const __gthread_time_t *abs_timeout);
127*18a5822eSThomas Veerman      int __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *m,
128*18a5822eSThomas Veerman                                           const __gthread_time_t *abs_time);
129*18a5822eSThomas Veerman 
130*18a5822eSThomas Veerman      int __gthread_cond_signal (__gthread_cond_t *cond);
131*18a5822eSThomas Veerman      int __gthread_cond_timedwait (__gthread_cond_t *cond,
132*18a5822eSThomas Veerman                                    __gthread_mutex_t *mutex,
133*18a5822eSThomas Veerman                                    const __gthread_time_t *abs_timeout);
134*18a5822eSThomas Veerman      int __gthread_cond_timedwait_recursive (__gthread_cond_t *cond,
135*18a5822eSThomas Veerman                                              __gthread_recursive_mutex_t *mutex,
136*18a5822eSThomas Veerman                                              const __gthread_time_t *abs_time)
137*18a5822eSThomas Veerman 
138*18a5822eSThomas Veerman    Currently supported threads packages are
139*18a5822eSThomas Veerman      TPF threads with -D__tpf__
140*18a5822eSThomas Veerman      POSIX/Unix98 threads with -D_PTHREADS
141*18a5822eSThomas Veerman      POSIX/Unix95 threads with -D_PTHREADS95
142*18a5822eSThomas Veerman      DCE threads with -D_DCE_THREADS
143*18a5822eSThomas Veerman      Solaris/UI threads with -D_SOLARIS_THREADS
144*18a5822eSThomas Veerman 
145*18a5822eSThomas Veerman */
146*18a5822eSThomas Veerman 
147*18a5822eSThomas Veerman /* Check first for thread specific defines.  */
148*18a5822eSThomas Veerman #if defined (_GLIBCXX___tpf_GLIBCXX___)
149*18a5822eSThomas Veerman #include <bits/gthr-tpf.h>
150*18a5822eSThomas Veerman #elif _GLIBCXX__PTHREADS
151*18a5822eSThomas Veerman #include <bits/gthr-posix.h>
152*18a5822eSThomas Veerman #elif _GLIBCXX__PTHREADS95
153*18a5822eSThomas Veerman #include <bits/gthr-posix95.h>
154*18a5822eSThomas Veerman #elif _GLIBCXX__DCE_THREADS
155*18a5822eSThomas Veerman #include <bits/gthr-dce.h>
156*18a5822eSThomas Veerman #elif _GLIBCXX__SOLARIS_THREADS
157*18a5822eSThomas Veerman #include <bits/gthr-solaris.h>
158*18a5822eSThomas Veerman 
159*18a5822eSThomas Veerman /* Include GTHREAD_FILE if one is defined.  */
160*18a5822eSThomas Veerman #elif defined(_GLIBCXX_HAVE_GTHR_DEFAULT)
161*18a5822eSThomas Veerman #if __GXX_WEAK__
162*18a5822eSThomas Veerman #ifndef _GLIBCXX_GTHREAD_USE_WEAK
163*18a5822eSThomas Veerman #define _GLIBCXX_GTHREAD_USE_WEAK 1
164*18a5822eSThomas Veerman #endif
165*18a5822eSThomas Veerman #endif
166*18a5822eSThomas Veerman #include <bits/gthr-default.h>
167*18a5822eSThomas Veerman 
168*18a5822eSThomas Veerman /* Fallback to single thread definitions.  */
169*18a5822eSThomas Veerman #else
170*18a5822eSThomas Veerman #include <bits/gthr-single.h>
171*18a5822eSThomas Veerman #endif
172*18a5822eSThomas Veerman 
173*18a5822eSThomas Veerman #ifndef _GLIBCXX_HIDE_EXPORTS
174*18a5822eSThomas Veerman #pragma GCC visibility pop
175*18a5822eSThomas Veerman #endif
176*18a5822eSThomas Veerman 
177*18a5822eSThomas Veerman #endif /* ! _GLIBCXX_GCC_GTHR_H */
178