annotate libgcc/gthr.h @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Threads compatibility routines for libgcc2. */
kono
parents:
diff changeset
2 /* Compile this one with gcc. */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
3 /* Copyright (C) 1997-2020 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 This file is part of GCC.
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 GCC is free software; you can redistribute it and/or modify it under
kono
parents:
diff changeset
8 the terms of the GNU General Public License as published by the Free
kono
parents:
diff changeset
9 Software Foundation; either version 3, or (at your option) any later
kono
parents:
diff changeset
10 version.
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
kono
parents:
diff changeset
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
kono
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
kono
parents:
diff changeset
15 for more details.
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 Under Section 7 of GPL version 3, you are granted additional
kono
parents:
diff changeset
18 permissions described in the GCC Runtime Library Exception, version
kono
parents:
diff changeset
19 3.1, as published by the Free Software Foundation.
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 You should have received a copy of the GNU General Public License and
kono
parents:
diff changeset
22 a copy of the GCC Runtime Library Exception along with this program;
kono
parents:
diff changeset
23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
kono
parents:
diff changeset
24 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 #ifndef GCC_GTHR_H
kono
parents:
diff changeset
27 #define GCC_GTHR_H
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 #ifndef HIDE_EXPORTS
kono
parents:
diff changeset
30 #pragma GCC visibility push(default)
kono
parents:
diff changeset
31 #endif
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 /* If this file is compiled with threads support, it must
kono
parents:
diff changeset
34 #define __GTHREADS 1
kono
parents:
diff changeset
35 to indicate that threads support is present. Also it has define
kono
parents:
diff changeset
36 function
kono
parents:
diff changeset
37 int __gthread_active_p ()
kono
parents:
diff changeset
38 that returns 1 if thread system is active, 0 if not.
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 The threads interface must define the following types:
kono
parents:
diff changeset
41 __gthread_key_t
kono
parents:
diff changeset
42 __gthread_once_t
kono
parents:
diff changeset
43 __gthread_mutex_t
kono
parents:
diff changeset
44 __gthread_recursive_mutex_t
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 The threads interface must define the following macros:
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 __GTHREAD_ONCE_INIT
kono
parents:
diff changeset
49 to initialize __gthread_once_t
kono
parents:
diff changeset
50 __GTHREAD_MUTEX_INIT
kono
parents:
diff changeset
51 to initialize __gthread_mutex_t to get a fast
kono
parents:
diff changeset
52 non-recursive mutex.
kono
parents:
diff changeset
53 __GTHREAD_MUTEX_INIT_FUNCTION
kono
parents:
diff changeset
54 to initialize __gthread_mutex_t to get a fast
kono
parents:
diff changeset
55 non-recursive mutex.
kono
parents:
diff changeset
56 Define this to a function which looks like this:
kono
parents:
diff changeset
57 void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *)
kono
parents:
diff changeset
58 Some systems can't initialize a mutex without a
kono
parents:
diff changeset
59 function call. Don't define __GTHREAD_MUTEX_INIT in this case.
kono
parents:
diff changeset
60 __GTHREAD_RECURSIVE_MUTEX_INIT
kono
parents:
diff changeset
61 __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
kono
parents:
diff changeset
62 as above, but for a recursive mutex.
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 The threads interface must define the following static functions:
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 int __gthread_once (__gthread_once_t *once, void (*func) ())
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 int __gthread_key_create (__gthread_key_t *keyp, void (*dtor) (void *))
kono
parents:
diff changeset
69 int __gthread_key_delete (__gthread_key_t key)
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 void *__gthread_getspecific (__gthread_key_t key)
kono
parents:
diff changeset
72 int __gthread_setspecific (__gthread_key_t key, const void *ptr)
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 int __gthread_mutex_destroy (__gthread_mutex_t *mutex);
kono
parents:
diff changeset
75 int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *mutex);
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 int __gthread_mutex_lock (__gthread_mutex_t *mutex);
kono
parents:
diff changeset
78 int __gthread_mutex_trylock (__gthread_mutex_t *mutex);
kono
parents:
diff changeset
79 int __gthread_mutex_unlock (__gthread_mutex_t *mutex);
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex);
kono
parents:
diff changeset
82 int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex);
kono
parents:
diff changeset
83 int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex);
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 The following are supported in POSIX threads only. They are required to
kono
parents:
diff changeset
86 fix a deadlock in static initialization inside libsupc++. The header file
kono
parents:
diff changeset
87 gthr-posix.h defines a symbol __GTHREAD_HAS_COND to signify that these extra
kono
parents:
diff changeset
88 features are supported.
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 Types:
kono
parents:
diff changeset
91 __gthread_cond_t
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 Macros:
kono
parents:
diff changeset
94 __GTHREAD_COND_INIT
kono
parents:
diff changeset
95 __GTHREAD_COND_INIT_FUNCTION
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 Interface:
kono
parents:
diff changeset
98 int __gthread_cond_broadcast (__gthread_cond_t *cond);
kono
parents:
diff changeset
99 int __gthread_cond_wait (__gthread_cond_t *cond, __gthread_mutex_t *mutex);
kono
parents:
diff changeset
100 int __gthread_cond_wait_recursive (__gthread_cond_t *cond,
kono
parents:
diff changeset
101 __gthread_recursive_mutex_t *mutex);
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 All functions returning int should return zero on success or the error
kono
parents:
diff changeset
104 number. If the operation is not supported, -1 is returned.
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 If the following are also defined, you should
kono
parents:
diff changeset
107 #define __GTHREADS_CXX0X 1
kono
parents:
diff changeset
108 to enable the c++0x thread library.
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 Types:
kono
parents:
diff changeset
111 __gthread_t
kono
parents:
diff changeset
112 __gthread_time_t
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 Interface:
kono
parents:
diff changeset
115 int __gthread_create (__gthread_t *thread, void *(*func) (void*),
kono
parents:
diff changeset
116 void *args);
kono
parents:
diff changeset
117 int __gthread_join (__gthread_t thread, void **value_ptr);
kono
parents:
diff changeset
118 int __gthread_detach (__gthread_t thread);
kono
parents:
diff changeset
119 int __gthread_equal (__gthread_t t1, __gthread_t t2);
kono
parents:
diff changeset
120 __gthread_t __gthread_self (void);
kono
parents:
diff changeset
121 int __gthread_yield (void);
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 int __gthread_mutex_timedlock (__gthread_mutex_t *m,
kono
parents:
diff changeset
124 const __gthread_time_t *abs_timeout);
kono
parents:
diff changeset
125 int __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *m,
kono
parents:
diff changeset
126 const __gthread_time_t *abs_time);
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 int __gthread_cond_signal (__gthread_cond_t *cond);
kono
parents:
diff changeset
129 int __gthread_cond_timedwait (__gthread_cond_t *cond,
kono
parents:
diff changeset
130 __gthread_mutex_t *mutex,
kono
parents:
diff changeset
131 const __gthread_time_t *abs_timeout);
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 */
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 #if SUPPORTS_WEAK
kono
parents:
diff changeset
136 /* The pe-coff weak support isn't fully compatible to ELF's weak.
kono
parents:
diff changeset
137 For static libraries it might would work, but as we need to deal
kono
parents:
diff changeset
138 with shared versions too, we disable it for mingw-targets. */
kono
parents:
diff changeset
139 #ifdef __MINGW32__
kono
parents:
diff changeset
140 #undef GTHREAD_USE_WEAK
kono
parents:
diff changeset
141 #define GTHREAD_USE_WEAK 0
kono
parents:
diff changeset
142 #endif
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 #ifndef GTHREAD_USE_WEAK
kono
parents:
diff changeset
145 #define GTHREAD_USE_WEAK 1
kono
parents:
diff changeset
146 #endif
kono
parents:
diff changeset
147 #endif
kono
parents:
diff changeset
148 #include "gthr-default.h"
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 #ifndef HIDE_EXPORTS
kono
parents:
diff changeset
151 #pragma GCC visibility pop
kono
parents:
diff changeset
152 #endif
kono
parents:
diff changeset
153
kono
parents:
diff changeset
154 #endif /* ! GCC_GTHR_H */