gthr.h

Go to the documentation of this file.
00001 /* Threads compatibility routines for libgcc2.  */
00002 /* Compile this one with gcc.  */
00003 /* Copyright (C) 1997, 1998, 2004 Free Software Foundation, Inc.
00004 
00005 This file is part of GCC.
00006 
00007 GCC is free software; you can redistribute it and/or modify it under
00008 the terms of the GNU General Public License as published by the Free
00009 Software Foundation; either version 2, or (at your option) any later
00010 version.
00011 
00012 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
00013 WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with GCC; see the file COPYING.  If not, write to the Free
00019 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
00020 02110-1301, USA.  */
00021 
00022 /* As a special exception, if you link this library with other files,
00023    some of which are compiled with GCC, to produce an executable,
00024    this library does not by itself cause the resulting executable
00025    to be covered by the GNU General Public License.
00026    This exception does not however invalidate any other reasons why
00027    the executable file might be covered by the GNU General Public License.  */
00028 
00029 #ifndef _GLIBCXX_GCC_GTHR_H
00030 #define _GLIBCXX_GCC_GTHR_H
00031 
00032 #ifndef _GLIBCXX_HIDE_EXPORTS
00033 #pragma GCC visibility push(default)
00034 #endif
00035 
00036 /* If this file is compiled with threads support, it must
00037        #define __GTHREADS 1
00038    to indicate that threads support is present.  Also it has define
00039    function
00040      int __gthread_active_p ()
00041    that returns 1 if thread system is active, 0 if not.
00042 
00043    The threads interface must define the following types:
00044      __gthread_key_t
00045      __gthread_once_t
00046      __gthread_mutex_t
00047      __gthread_recursive_mutex_t
00048 
00049    The threads interface must define the following macros:
00050 
00051      __GTHREAD_ONCE_INIT
00052             to initialize __gthread_once_t
00053      __GTHREAD_MUTEX_INIT
00054             to initialize __gthread_mutex_t to get a fast
00055         non-recursive mutex.
00056      __GTHREAD_MUTEX_INIT_FUNCTION
00057             some systems can't initialize a mutex without a
00058         function call.  On such systems, define this to a
00059         function which looks like this:
00060           void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *)
00061         Don't define __GTHREAD_MUTEX_INIT in this case
00062      __GTHREAD_RECURSIVE_MUTEX_INIT
00063      __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
00064             as above, but for a recursive mutex.
00065 
00066    The threads interface must define the following static functions:
00067 
00068      int __gthread_once (__gthread_once_t *once, void (*func) ())
00069 
00070      int __gthread_key_create (__gthread_key_t *keyp, void (*dtor) (void *))
00071      int __gthread_key_delete (__gthread_key_t key)
00072 
00073      void *__gthread_getspecific (__gthread_key_t key)
00074      int __gthread_setspecific (__gthread_key_t key, const void *ptr)
00075 
00076      int __gthread_mutex_lock (__gthread_mutex_t *mutex);
00077      int __gthread_mutex_trylock (__gthread_mutex_t *mutex);
00078      int __gthread_mutex_unlock (__gthread_mutex_t *mutex);
00079 
00080      int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex);
00081      int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex);
00082      int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex);
00083 
00084    The following are supported in POSIX threads only. They are required to
00085    fix a deadlock in static initialization inside libsupc++. The header file
00086    gthr-posix.h defines a symbol __GTHREAD_HAS_COND to signify that these extra
00087    features are supported.
00088 
00089    Types:
00090      __gthread_cond_t
00091 
00092    Macros:
00093      __GTHREAD_COND_INIT
00094      __GTHREAD_COND_INIT_FUNCTION
00095 
00096    Interface:
00097      int __gthread_cond_broadcast (__gthread_cond_t *cond);
00098      int __gthread_cond_wait (__gthread_cond_t *cond, __gthread_mutex_t *mutex);
00099      int __gthread_cond_wait_recursive (__gthread_cond_t *cond,
00100                     __gthread_recursive_mutex_t *mutex);
00101 
00102    All functions returning int should return zero on success or the error
00103    number.  If the operation is not supported, -1 is returned.
00104 
00105    Currently supported threads packages are
00106      TPF threads with -D__tpf__
00107      POSIX/Unix98 threads with -D_PTHREADS
00108      POSIX/Unix95 threads with -D_PTHREADS95
00109      DCE threads with -D_DCE_THREADS
00110      Solaris/UI threads with -D_SOLARIS_THREADS
00111 */
00112 
00113 /* Check first for thread specific defines.  */
00114 #if defined (_GLIBCXX___tpf_GLIBCXX___)
00115 #include <bits/gthr-tpf.h>
00116 #elif _GLIBCXX__PTHREADS
00117 #include <bits/gthr-posix.h>
00118 #elif _GLIBCXX__PTHREADS95
00119 #include <bits/gthr-posix95.h>
00120 #elif _GLIBCXX__DCE_THREADS
00121 #include <bits/gthr-dce.h>
00122 #elif _GLIBCXX__SOLARIS_THREADS
00123 #include <bits/gthr-solaris.h>
00124 
00125 /* Include GTHREAD_FILE if one is defined.  */
00126 #elif defined(_GLIBCXX_HAVE_GTHR_DEFAULT)
00127 #if __GXX_WEAK__
00128 #ifndef _GLIBCXX_GTHREAD_USE_WEAK
00129 #define _GLIBCXX_GTHREAD_USE_WEAK 1
00130 #endif
00131 #endif
00132 #include <bits/gthr-default.h>
00133 
00134 /* Fallback to single thread definitions.  */
00135 #else
00136 #include <bits/gthr-single.h>
00137 #endif
00138 
00139 #ifndef _GLIBCXX_HIDE_EXPORTS
00140 #pragma GCC visibility pop
00141 #endif
00142 
00143 #endif /* ! _GLIBCXX_GCC_GTHR_H */

Generated on Tue Feb 2 16:55:58 2010 for GNU C++ STL by  doxygen 1.4.7