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