1/* Threads compatibility routines for libgcc2.  */
2/* Compile this one with gcc.  */
3/* Copyright (C) 1997, 1998, 2004 Free Software Foundation, Inc.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 2, or (at your option) any later
10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING.  If not, write to the Free
19Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
2002110-1301, 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 GCC_GTHR_H
30#define GCC_GTHR_H
31
32#ifndef HIDE_EXPORTS
33#pragma GCC visibility push(default)
34#endif
35
36/* If this file is compiled with threads support, it must
37       #define __GTHREADS 1
38   to indicate that threads support is present.  Also it has define
39   function
40     int __gthread_active_p ()
41   that returns 1 if thread system is active, 0 if not.
42
43   The threads interface must define the following types:
44     __gthread_key_t
45     __gthread_once_t
46     __gthread_mutex_t
47     __gthread_recursive_mutex_t
48
49   The threads interface must define the following macros:
50
51     __GTHREAD_ONCE_INIT
52     		to initialize __gthread_once_t
53     __GTHREAD_MUTEX_INIT
54     		to initialize __gthread_mutex_t to get a fast
55		non-recursive mutex.
56     __GTHREAD_MUTEX_INIT_FUNCTION
57     		some systems can't initialize a mutex without a
58		function call.  On such systems, define this to a
59		function which looks like this:
60		  void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *)
61		Don't define __GTHREAD_MUTEX_INIT in this case
62     __GTHREAD_RECURSIVE_MUTEX_INIT
63     __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
64     		as above, but for a recursive mutex.
65
66   The threads interface must define the following static functions:
67
68     int __gthread_once (__gthread_once_t *once, void (*func) ())
69
70     int __gthread_key_create (__gthread_key_t *keyp, void (*dtor) (void *))
71     int __gthread_key_delete (__gthread_key_t key)
72
73     void *__gthread_getspecific (__gthread_key_t key)
74     int __gthread_setspecific (__gthread_key_t key, const void *ptr)
75
76     int __gthread_mutex_lock (__gthread_mutex_t *mutex);
77     int __gthread_mutex_trylock (__gthread_mutex_t *mutex);
78     int __gthread_mutex_unlock (__gthread_mutex_t *mutex);
79
80     int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex);
81     int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex);
82     int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex);
83
84   All functions returning int should return zero on success or the error
85   number.  If the operation is not supported, -1 is returned.
86
87   Currently supported threads packages are
88     TPF threads with -D__tpf__
89     POSIX/Unix98 threads with -D_PTHREADS
90     POSIX/Unix95 threads with -D_PTHREADS95
91     DCE threads with -D_DCE_THREADS
92     Solaris/UI threads with -D_SOLARIS_THREADS
93*/
94
95/* Check first for thread specific defines.  */
96#if defined (__tpf__)
97#include "gthr-tpf.h"
98#elif _PTHREADS
99#include "gthr-posix.h"
100#elif _PTHREADS95
101#include "gthr-posix95.h"
102#elif _DCE_THREADS
103#include "gthr-dce.h"
104#elif _SOLARIS_THREADS
105#include "gthr-solaris.h"
106
107/* Include GTHREAD_FILE if one is defined.  */
108#elif defined(HAVE_GTHR_DEFAULT)
109#if SUPPORTS_WEAK
110#ifndef GTHREAD_USE_WEAK
111#define GTHREAD_USE_WEAK 1
112#endif
113#endif
114#include "gthr-default.h"
115
116/* Fallback to single thread definitions.  */
117#else
118#include "gthr-single.h"
119#endif
120
121#ifndef HIDE_EXPORTS
122#pragma GCC visibility pop
123#endif
124
125#endif /* ! GCC_GTHR_H */
126