gthr.h

00001 /* Threads compatibility routines for libgcc2.  */
00002 /* Compile this one with gcc.  */
00003 /* Copyright (C) 1997, 1998 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, 59 Temple Place - Suite 330, Boston, MA
00020 02111-1307, 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 _GLIBCPP_GCC_GTHR_H
00030 #define _GLIBCPP_GCC_GTHR_H
00031 
00032 /* If this file is compiled with threads support, it must
00033        #define __GTHREADS 1
00034    to indicate that threads support is present.  Also it has define
00035    function
00036      int __gthread_active_p ()
00037    that returns 1 if thread system is active, 0 if not.
00038 
00039    The threads interface must define the following types:
00040      __gthread_key_t
00041      __gthread_once_t
00042      __gthread_mutex_t
00043 
00044    The threads interface must define the following macros:
00045 
00046      __GTHREAD_ONCE_INIT
00047             to initialize __gthread_once_t
00048      __GTHREAD_MUTEX_INIT
00049             to initialize __gthread_mutex_t to get a fast
00050         non-recursive mutex.
00051      __GTHREAD_MUTEX_INIT_FUNCTION
00052             some systems can't initialize a mutex without a
00053         function call.  On such systems, define this to a
00054         function which looks like this:
00055           void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *)
00056         Don't define __GTHREAD_MUTEX_INIT in this case
00057 
00058    The threads interface must define the following static functions:
00059 
00060      int __gthread_once (__gthread_once_t *once, void (*func) ())
00061 
00062      int __gthread_key_create (__gthread_key_t *keyp, void (*dtor) (void *))
00063      int __gthread_key_delete (__gthread_key_t key)
00064 
00065      int __gthread_key_dtor (__gthread_key_t key, void *ptr)
00066 
00067      void *__gthread_getspecific (__gthread_key_t key)
00068      int __gthread_setspecific (__gthread_key_t key, const void *ptr)
00069 
00070      int __gthread_mutex_lock (__gthread_mutex_t *mutex);
00071      int __gthread_mutex_trylock (__gthread_mutex_t *mutex);
00072      int __gthread_mutex_unlock (__gthread_mutex_t *mutex);
00073 
00074    All functions returning int should return zero on success or the error
00075    number.  If the operation is not supported, -1 is returned.
00076 
00077    Currently supported threads packages are
00078      POSIX threads with -D_PTHREADS
00079      DCE threads with -D_DCE_THREADS
00080      Solaris/UI threads with -D_SOLARIS_THREADS
00081 */
00082 
00083 /* Check first for thread specific defines.  */
00084 #if _GLIBCPP__PTHREADS
00085 #include <bits/gthr-posix.h>
00086 #elif _GLIBCPP__DCE_THREADS
00087 #include <bits/gthr-dce.h>
00088 #elif _GLIBCPP__SOLARIS_THREADS
00089 #include <bits/gthr-solaris.h>
00090 
00091 /* Include GTHREAD_FILE if one is defined.  */
00092 #elif defined(_GLIBCPP_HAVE_GTHR_DEFAULT)
00093 #if _GLIBCPP_SUPPORTS_WEAK
00094 #ifndef _GLIBCPP_GTHREAD_USE_WEAK
00095 #define _GLIBCPP_GTHREAD_USE_WEAK 1
00096 #endif
00097 #endif
00098 #include <bits/gthr-default.h>
00099 
00100 /* Fallback to single thread definitions.  */
00101 #else
00102 #include <bits/gthr-single.h>
00103 #endif
00104 
00105 #endif /* ! _GLIBCPP_GCC_GTHR_H */

Generated on Thu Feb 10 23:22:54 2005 for libstdc++-v3 Source by  doxygen 1.4.0