| 1 | /* Threads compatibility routines for libgcc2. */ |
|---|
| 2 | /* Compile this one with gcc. */ |
|---|
| 3 | /* Copyright (C) 1997, 1998 Free Software Foundation, Inc. |
|---|
| 4 | |
|---|
| 5 | This file is part of GCC. |
|---|
| 6 | |
|---|
| 7 | GCC is free software; you can redistribute it and/or modify it under |
|---|
| 8 | the terms of the GNU General Public License as published by the Free |
|---|
| 9 | Software Foundation; either version 2, or (at your option) any later |
|---|
| 10 | version. |
|---|
| 11 | |
|---|
| 12 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
|---|
| 13 | WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 14 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|---|
| 15 | for more details. |
|---|
| 16 | |
|---|
| 17 | You should have received a copy of the GNU General Public License |
|---|
| 18 | along with GCC; see the file COPYING. If not, write to the Free |
|---|
| 19 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA |
|---|
| 20 | 02111-1307, USA. */ |
|---|
| 21 | |
|---|
| 22 | /* As a special exception, if you link this library with other files, |
|---|
| 23 | some of which are compiled with GCC, to produce an executable, |
|---|
| 24 | this library does not by itself cause the resulting executable |
|---|
| 25 | to be covered by the GNU General Public License. |
|---|
| 26 | This exception does not however invalidate any other reasons why |
|---|
| 27 | the executable file might be covered by the GNU General Public License. */ |
|---|
| 28 | |
|---|
| 29 | #ifndef _GLIBCXX_GCC_GTHR_H |
|---|
| 30 | #define _GLIBCXX_GCC_GTHR_H |
|---|
| 31 | |
|---|
| 32 | /* If this file is compiled with threads support, it must |
|---|
| 33 | #define __GTHREADS 1 |
|---|
| 34 | to indicate that threads support is present. Also it has define |
|---|
| 35 | function |
|---|
| 36 | int __gthread_active_p () |
|---|
| 37 | that returns 1 if thread system is active, 0 if not. |
|---|
| 38 | |
|---|
| 39 | The threads interface must define the following types: |
|---|
| 40 | __gthread_key_t |
|---|
| 41 | __gthread_once_t |
|---|
| 42 | __gthread_mutex_t |
|---|
| 43 | |
|---|
| 44 | The threads interface must define the following macros: |
|---|
| 45 | |
|---|
| 46 | __GTHREAD_ONCE_INIT |
|---|
| 47 | to initialize __gthread_once_t |
|---|
| 48 | __GTHREAD_MUTEX_INIT |
|---|
| 49 | to initialize __gthread_mutex_t to get a fast |
|---|
| 50 | non-recursive mutex. |
|---|
| 51 | __GTHREAD_MUTEX_INIT_FUNCTION |
|---|
| 52 | some systems can't initialize a mutex without a |
|---|
| 53 | function call. On such systems, define this to a |
|---|
| 54 | function which looks like this: |
|---|
| 55 | void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *) |
|---|
| 56 | Don't define __GTHREAD_MUTEX_INIT in this case |
|---|
| 57 | |
|---|
| 58 | The threads interface must define the following static functions: |
|---|
| 59 | |
|---|
| 60 | int __gthread_once (__gthread_once_t *once, void (*func) ()) |
|---|
| 61 | |
|---|
| 62 | int __gthread_key_create (__gthread_key_t *keyp, void (*dtor) (void *)) |
|---|
| 63 | int __gthread_key_delete (__gthread_key_t key) |
|---|
| 64 | |
|---|
| 65 | void *__gthread_getspecific (__gthread_key_t key) |
|---|
| 66 | int __gthread_setspecific (__gthread_key_t key, const void *ptr) |
|---|
| 67 | |
|---|
| 68 | int __gthread_mutex_lock (__gthread_mutex_t *mutex); |
|---|
| 69 | int __gthread_mutex_trylock (__gthread_mutex_t *mutex); |
|---|
| 70 | int __gthread_mutex_unlock (__gthread_mutex_t *mutex); |
|---|
| 71 | |
|---|
| 72 | All functions returning int should return zero on success or the error |
|---|
| 73 | number. If the operation is not supported, -1 is returned. |
|---|
| 74 | |
|---|
| 75 | Currently supported threads packages are |
|---|
| 76 | POSIX threads with -D_PTHREADS |
|---|
| 77 | DCE threads with -D_DCE_THREADS |
|---|
| 78 | Solaris/UI threads with -D_SOLARIS_THREADS |
|---|
| 79 | */ |
|---|
| 80 | |
|---|
| 81 | /* Check first for thread specific defines. */ |
|---|
| 82 | #if _GLIBCXX__PTHREADS |
|---|
| 83 | #include <bits/gthr-posix.h> |
|---|
| 84 | #elif _GLIBCXX__DCE_THREADS |
|---|
| 85 | #include <bits/gthr-dce.h> |
|---|
| 86 | #elif _GLIBCXX__SOLARIS_THREADS |
|---|
| 87 | #include <bits/gthr-solaris.h> |
|---|
| 88 | |
|---|
| 89 | /* Include GTHREAD_FILE if one is defined. */ |
|---|
| 90 | #elif defined(_GLIBCXX_HAVE_GTHR_DEFAULT) |
|---|
| 91 | #if __GXX_WEAK__ |
|---|
| 92 | #ifndef _GLIBCXX_GTHREAD_USE_WEAK |
|---|
| 93 | #define _GLIBCXX_GTHREAD_USE_WEAK 1 |
|---|
| 94 | #endif |
|---|
| 95 | #endif |
|---|
| 96 | #include <bits/gthr-default.h> |
|---|
| 97 | |
|---|
| 98 | /* Fallback to single thread definitions. */ |
|---|
| 99 | #else |
|---|
| 100 | #include <bits/gthr-single.h> |
|---|
| 101 | #endif |
|---|
| 102 | |
|---|
| 103 | #endif /* ! _GLIBCXX_GCC_GTHR_H */ |
|---|