]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/gthr.h
re PR tree-optimization/37005 (GNAT Bug Box for cd2a24e.adb:37 at tree-vrp.c:392)
[thirdparty/gcc.git] / gcc / gthr.h
CommitLineData
899905f6 1/* Threads compatibility routines for libgcc2. */
f24af81b 2/* Compile this one with gcc. */
279b5b3c 3/* Copyright (C) 1997, 1998, 2004 Free Software Foundation, Inc.
f24af81b 4
1322177d 5This file is part of GCC.
f24af81b 6
1322177d
LB
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.
f24af81b 11
1322177d
LB
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.
f24af81b
TT
16
17You should have received a copy of the GNU General Public License
1322177d 18along with GCC; see the file COPYING. If not, write to the Free
366ccddb
KC
19Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
2002110-1301, USA. */
f24af81b
TT
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
88657302
RH
29#ifndef GCC_GTHR_H
30#define GCC_GTHR_H
f24af81b 31
7370bebd 32#ifndef HIDE_EXPORTS
3fc1f660 33#pragma GCC visibility push(default)
7370bebd 34#endif
3fc1f660 35
f24af81b
TT
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
589005ff 39 function
f24af81b
TT
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
40aac948 47 __gthread_recursive_mutex_t
f24af81b
TT
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.
3e2a2957 56 __GTHREAD_MUTEX_INIT_FUNCTION
f63d1bf7 57 some systems can't initialize a mutex without a
3e2a2957
TT
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
40aac948
JM
62 __GTHREAD_RECURSIVE_MUTEX_INIT
63 __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
64 as above, but for a recursive mutex.
f24af81b
TT
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
f24af81b
TT
73 void *__gthread_getspecific (__gthread_key_t key)
74 int __gthread_setspecific (__gthread_key_t key, const void *ptr)
75
4dabf736
JB
76 int __gthread_mutex_destroy (__gthread_mutex_t *mutex);
77
f24af81b
TT
78 int __gthread_mutex_lock (__gthread_mutex_t *mutex);
79 int __gthread_mutex_trylock (__gthread_mutex_t *mutex);
80 int __gthread_mutex_unlock (__gthread_mutex_t *mutex);
81
40aac948
JM
82 int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex);
83 int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex);
84 int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex);
afd82ef5
DK
85
86 The following are supported in POSIX threads only. They are required to
87 fix a deadlock in static initialization inside libsupc++. The header file
88 gthr-posix.h defines a symbol __GTHREAD_HAS_COND to signify that these extra
89 features are supported.
90
91 Types:
92 __gthread_cond_t
93
94 Macros:
95 __GTHREAD_COND_INIT
96 __GTHREAD_COND_INIT_FUNCTION
97
98 Interface:
99 int __gthread_cond_broadcast (__gthread_cond_t *cond);
100 int __gthread_cond_wait (__gthread_cond_t *cond, __gthread_mutex_t *mutex);
101 int __gthread_cond_wait_recursive (__gthread_cond_t *cond,
102 __gthread_recursive_mutex_t *mutex);
40aac948 103
754d1a92
TT
104 All functions returning int should return zero on success or the error
105 number. If the operation is not supported, -1 is returned.
f24af81b
TT
106
107 Currently supported threads packages are
18167442
EB
108 TPF threads with -D__tpf__
109 POSIX/Unix98 threads with -D_PTHREADS
110 POSIX/Unix95 threads with -D_PTHREADS95
f24af81b
TT
111 DCE threads with -D_DCE_THREADS
112 Solaris/UI threads with -D_SOLARIS_THREADS
113*/
114
19eb1ad7 115/* Check first for thread specific defines. */
512baaea
D
116#if defined (__tpf__)
117#include "gthr-tpf.h"
118#elif _PTHREADS
f24af81b 119#include "gthr-posix.h"
18167442
EB
120#elif _PTHREADS95
121#include "gthr-posix95.h"
f24af81b
TT
122#elif _DCE_THREADS
123#include "gthr-dce.h"
124#elif _SOLARIS_THREADS
125#include "gthr-solaris.h"
126
19eb1ad7 127/* Include GTHREAD_FILE if one is defined. */
7cc34889
MS
128#elif defined(HAVE_GTHR_DEFAULT)
129#if SUPPORTS_WEAK
f24af81b
TT
130#ifndef GTHREAD_USE_WEAK
131#define GTHREAD_USE_WEAK 1
132#endif
7cc34889 133#endif
f24af81b
TT
134#include "gthr-default.h"
135
19eb1ad7 136/* Fallback to single thread definitions. */
f24af81b
TT
137#else
138#include "gthr-single.h"
139#endif
140
7370bebd 141#ifndef HIDE_EXPORTS
b3f8d95d 142#pragma GCC visibility pop
7370bebd 143#endif
3fc1f660 144
88657302 145#endif /* ! GCC_GTHR_H */