1 /* Threads compatibily routines for libgcc2. */
2 /* Compile this one with gcc. */
3 /* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
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. */
32 /* If this file is compiled with threads support, it must
34 to indicate that threads support is present. Also it has define
36 int __gthread_active_p ()
37 that returns 1 if thread system is active, 0 if not.
39 The threads interface must define the following types:
44 The threads interface must define the following macros:
47 to initialize __gthread_once_t
49 to initialize __gthread_mutex_t to get a fast
51 __GTHREAD_MUTEX_INIT_FUNCTION
52 some systems can't initalize 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
58 The threads interface must define the following static functions:
60 int __gthread_once (__gthread_once_t *once, void (*func) ())
62 int __gthread_key_create (__gthread_key_t *keyp, void (*dtor) (void *))
63 int __gthread_key_delete (__gthread_key_t key)
65 int __gthread_key_dtor (__gthread_key_t key, void *ptr)
67 void *__gthread_getspecific (__gthread_key_t key)
68 int __gthread_setspecific (__gthread_key_t key, const void *ptr)
70 int __gthread_mutex_lock (__gthread_mutex_t *mutex);
71 int __gthread_mutex_trylock (__gthread_mutex_t *mutex);
72 int __gthread_mutex_unlock (__gthread_mutex_t *mutex);
74 All functions returning int should return zero on success or the error
75 number. If the operation is not supported, -1 is returned.
77 Currently supported threads packages are
78 POSIX threads with -D_PTHREADS
79 DCE threads with -D_DCE_THREADS
80 Solaris/UI threads with -D_SOLARIS_THREADS
83 /* Check first for thread specific defines. */
85 #include "gthr-posix.h"
88 #elif _SOLARIS_THREADS
89 #include "gthr-solaris.h"
91 /* Include GTHREAD_FILE if one is defined. */
92 #elif defined(HAVE_GTHR_DEFAULT)
94 #ifndef GTHREAD_USE_WEAK
95 #define GTHREAD_USE_WEAK 1
98 #include "gthr-default.h"
100 /* Fallback to single thread definitions. */
102 #include "gthr-single.h"
105 #endif /* not __gthr_h */