]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgcc/gthr.h
PR c++/87554 - ICE with extern template and reference member.
[thirdparty/gcc.git] / libgcc / gthr.h
CommitLineData
00a2e859 1/* Threads compatibility routines for libgcc2. */
58febf9e 2/* Compile this one with gcc. */
fbd26352 3/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
58febf9e 4
f12b58b3 5This file is part of GCC.
58febf9e 6
f12b58b3 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
6bc9506f 9Software Foundation; either version 3, or (at your option) any later
f12b58b3 10version.
58febf9e 11
f12b58b3 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.
58febf9e 16
6bc9506f 17Under Section 7 of GPL version 3, you are granted additional
18permissions described in the GCC Runtime Library Exception, version
193.1, as published by the Free Software Foundation.
20
21You should have received a copy of the GNU General Public License and
22a copy of the GCC Runtime Library Exception along with this program;
23see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24<http://www.gnu.org/licenses/>. */
58febf9e 25
2a281353 26#ifndef GCC_GTHR_H
27#define GCC_GTHR_H
58febf9e 28
cca0d0c6 29#ifndef HIDE_EXPORTS
bc9fbf5d 30#pragma GCC visibility push(default)
cca0d0c6 31#endif
bc9fbf5d 32
58febf9e 33/* If this file is compiled with threads support, it must
34 #define __GTHREADS 1
35 to indicate that threads support is present. Also it has define
3cfec666 36 function
58febf9e 37 int __gthread_active_p ()
38 that returns 1 if thread system is active, 0 if not.
39
40 The threads interface must define the following types:
41 __gthread_key_t
42 __gthread_once_t
43 __gthread_mutex_t
4813f5af 44 __gthread_recursive_mutex_t
58febf9e 45
46 The threads interface must define the following macros:
47
48 __GTHREAD_ONCE_INIT
49 to initialize __gthread_once_t
50 __GTHREAD_MUTEX_INIT
51 to initialize __gthread_mutex_t to get a fast
52 non-recursive mutex.
2022c24b 53 __GTHREAD_MUTEX_INIT_FUNCTION
2e7d9be1 54 to initialize __gthread_mutex_t to get a fast
55 non-recursive mutex.
56 Define this to a function which looks like this:
2022c24b 57 void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *)
2e7d9be1 58 Some systems can't initialize a mutex without a
59 function call. Don't define __GTHREAD_MUTEX_INIT in this case.
4813f5af 60 __GTHREAD_RECURSIVE_MUTEX_INIT
61 __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
62 as above, but for a recursive mutex.
58febf9e 63
64 The threads interface must define the following static functions:
65
66 int __gthread_once (__gthread_once_t *once, void (*func) ())
67
68 int __gthread_key_create (__gthread_key_t *keyp, void (*dtor) (void *))
69 int __gthread_key_delete (__gthread_key_t key)
70
58febf9e 71 void *__gthread_getspecific (__gthread_key_t key)
72 int __gthread_setspecific (__gthread_key_t key, const void *ptr)
73
1cd3a344 74 int __gthread_mutex_destroy (__gthread_mutex_t *mutex);
4854adab 75 int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *mutex);
1cd3a344 76
58febf9e 77 int __gthread_mutex_lock (__gthread_mutex_t *mutex);
78 int __gthread_mutex_trylock (__gthread_mutex_t *mutex);
79 int __gthread_mutex_unlock (__gthread_mutex_t *mutex);
80
4813f5af 81 int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex);
82 int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex);
83 int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex);
c0aa46db 84
85 The following are supported in POSIX threads only. They are required to
86 fix a deadlock in static initialization inside libsupc++. The header file
87 gthr-posix.h defines a symbol __GTHREAD_HAS_COND to signify that these extra
88 features are supported.
89
90 Types:
91 __gthread_cond_t
92
93 Macros:
94 __GTHREAD_COND_INIT
95 __GTHREAD_COND_INIT_FUNCTION
96
97 Interface:
98 int __gthread_cond_broadcast (__gthread_cond_t *cond);
99 int __gthread_cond_wait (__gthread_cond_t *cond, __gthread_mutex_t *mutex);
100 int __gthread_cond_wait_recursive (__gthread_cond_t *cond,
101 __gthread_recursive_mutex_t *mutex);
4813f5af 102
f8809366 103 All functions returning int should return zero on success or the error
104 number. If the operation is not supported, -1 is returned.
58febf9e 105
48e1416a 106 If the following are also defined, you should
3fbf11ef 107 #define __GTHREADS_CXX0X 1
48e1416a 108 to enable the c++0x thread library.
109
3fbf11ef 110 Types:
111 __gthread_t
112 __gthread_time_t
113
114 Interface:
48e1416a 115 int __gthread_create (__gthread_t *thread, void *(*func) (void*),
3fbf11ef 116 void *args);
117 int __gthread_join (__gthread_t thread, void **value_ptr);
118 int __gthread_detach (__gthread_t thread);
119 int __gthread_equal (__gthread_t t1, __gthread_t t2);
120 __gthread_t __gthread_self (void);
121 int __gthread_yield (void);
122
123 int __gthread_mutex_timedlock (__gthread_mutex_t *m,
124 const __gthread_time_t *abs_timeout);
125 int __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *m,
126 const __gthread_time_t *abs_time);
48e1416a 127
3fbf11ef 128 int __gthread_cond_signal (__gthread_cond_t *cond);
48e1416a 129 int __gthread_cond_timedwait (__gthread_cond_t *cond,
3fbf11ef 130 __gthread_mutex_t *mutex,
131 const __gthread_time_t *abs_timeout);
3fbf11ef 132
58febf9e 133*/
134
26fbb0d3 135#if SUPPORTS_WEAK
52cec843 136/* The pe-coff weak support isn't fully compatible to ELF's weak.
137 For static libraries it might would work, but as we need to deal
138 with shared versions too, we disable it for mingw-targets. */
139#ifdef __MINGW32__
140#undef GTHREAD_USE_WEAK
141#define GTHREAD_USE_WEAK 0
142#endif
143
58febf9e 144#ifndef GTHREAD_USE_WEAK
145#define GTHREAD_USE_WEAK 1
146#endif
26fbb0d3 147#endif
58febf9e 148#include "gthr-default.h"
149
cca0d0c6 150#ifndef HIDE_EXPORTS
30e9913f 151#pragma GCC visibility pop
cca0d0c6 152#endif
bc9fbf5d 153
2a281353 154#endif /* ! GCC_GTHR_H */