]>
Commit | Line | Data |
---|---|---|
2b778ceb | 1 | /* Copyright (C) 2002-2021 Free Software Foundation, Inc. |
76a50749 UD |
2 | This file is part of the GNU C Library. |
3 | Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. | |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
6 | modify it under the terms of the GNU Lesser General Public | |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
9 | ||
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | Lesser General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
59ba27a6 | 16 | License along with the GNU C Library; if not, see |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
76a50749 UD |
18 | |
19 | #ifndef _PTHREADP_H | |
20 | #define _PTHREADP_H 1 | |
21 | ||
a25077a4 ST |
22 | #define __PTHREAD_NPTL |
23 | ||
76a50749 UD |
24 | #include <pthread.h> |
25 | #include <setjmp.h> | |
b758b9cb | 26 | #include <stdbool.h> |
76a50749 UD |
27 | #include <sys/syscall.h> |
28 | #include "descr.h" | |
29 | #include <tls.h> | |
30 | #include <lowlevellock.h> | |
31 | #include <stackinfo.h> | |
32 | #include <internaltypes.h> | |
86246935 | 33 | #include <atomic.h> |
0f6699ea | 34 | #include <kernel-features.h> |
da1304bc | 35 | #include <errno.h> |
92aabad9 | 36 | #include <internal-signals.h> |
6310e6be | 37 | #include "pthread_mutex_conf.h" |
23fe486b | 38 | |
76a50749 | 39 | |
a1b5424f UD |
40 | /* Atomic operations on TLS memory. */ |
41 | #ifndef THREAD_ATOMIC_CMPXCHG_VAL | |
42 | # define THREAD_ATOMIC_CMPXCHG_VAL(descr, member, new, old) \ | |
43 | atomic_compare_and_exchange_val_acq (&(descr)->member, new, old) | |
44 | #endif | |
45 | ||
46 | #ifndef THREAD_ATOMIC_BIT_SET | |
47 | # define THREAD_ATOMIC_BIT_SET(descr, member, bit) \ | |
48 | atomic_bit_set (&(descr)->member, bit) | |
49 | #endif | |
50 | ||
51 | ||
6310e6be KW |
52 | static inline short max_adaptive_count (void) |
53 | { | |
54 | #if HAVE_TUNABLES | |
55 | return __mutex_aconf.spin_count; | |
56 | #else | |
57 | return DEFAULT_ADAPTIVE_COUNT; | |
2c0b891a | 58 | #endif |
6310e6be | 59 | } |
2c0b891a UD |
60 | |
61 | ||
1bcfb5a5 | 62 | /* Magic cookie representing robust mutex with dead owner. */ |
683040c3 | 63 | #define PTHREAD_MUTEX_INCONSISTENT INT_MAX |
1bcfb5a5 UD |
64 | /* Magic cookie representing not recoverable robust mutex. */ |
65 | #define PTHREAD_MUTEX_NOTRECOVERABLE (INT_MAX - 1) | |
66 | ||
67 | ||
68 | /* Internal mutex type value. */ | |
69 | enum | |
70 | { | |
df47504c | 71 | PTHREAD_MUTEX_KIND_MASK_NP = 3, |
b023e4ca AK |
72 | |
73 | PTHREAD_MUTEX_ELISION_NP = 256, | |
74 | PTHREAD_MUTEX_NO_ELISION_NP = 512, | |
75 | ||
0f6699ea UD |
76 | PTHREAD_MUTEX_ROBUST_NORMAL_NP = 16, |
77 | PTHREAD_MUTEX_ROBUST_RECURSIVE_NP | |
78 | = PTHREAD_MUTEX_ROBUST_NORMAL_NP | PTHREAD_MUTEX_RECURSIVE_NP, | |
79 | PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP | |
80 | = PTHREAD_MUTEX_ROBUST_NORMAL_NP | PTHREAD_MUTEX_ERRORCHECK_NP, | |
81 | PTHREAD_MUTEX_ROBUST_ADAPTIVE_NP | |
82 | = PTHREAD_MUTEX_ROBUST_NORMAL_NP | PTHREAD_MUTEX_ADAPTIVE_NP, | |
df47504c UD |
83 | PTHREAD_MUTEX_PRIO_INHERIT_NP = 32, |
84 | PTHREAD_MUTEX_PI_NORMAL_NP | |
85 | = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_NORMAL, | |
86 | PTHREAD_MUTEX_PI_RECURSIVE_NP | |
87 | = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_RECURSIVE_NP, | |
88 | PTHREAD_MUTEX_PI_ERRORCHECK_NP | |
89 | = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ERRORCHECK_NP, | |
90 | PTHREAD_MUTEX_PI_ADAPTIVE_NP | |
91 | = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ADAPTIVE_NP, | |
92 | PTHREAD_MUTEX_PI_ROBUST_NORMAL_NP | |
93 | = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_NORMAL_NP, | |
94 | PTHREAD_MUTEX_PI_ROBUST_RECURSIVE_NP | |
95 | = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_RECURSIVE_NP, | |
96 | PTHREAD_MUTEX_PI_ROBUST_ERRORCHECK_NP | |
97 | = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP, | |
98 | PTHREAD_MUTEX_PI_ROBUST_ADAPTIVE_NP | |
99 | = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_ADAPTIVE_NP, | |
f17efcb4 UD |
100 | PTHREAD_MUTEX_PRIO_PROTECT_NP = 64, |
101 | PTHREAD_MUTEX_PP_NORMAL_NP | |
102 | = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_NORMAL, | |
103 | PTHREAD_MUTEX_PP_RECURSIVE_NP | |
104 | = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_RECURSIVE_NP, | |
105 | PTHREAD_MUTEX_PP_ERRORCHECK_NP | |
106 | = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_ERRORCHECK_NP, | |
107 | PTHREAD_MUTEX_PP_ADAPTIVE_NP | |
b023e4ca AK |
108 | = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_ADAPTIVE_NP, |
109 | PTHREAD_MUTEX_ELISION_FLAGS_NP | |
110 | = PTHREAD_MUTEX_ELISION_NP | PTHREAD_MUTEX_NO_ELISION_NP, | |
111 | ||
112 | PTHREAD_MUTEX_TIMED_ELISION_NP = | |
113 | PTHREAD_MUTEX_TIMED_NP | PTHREAD_MUTEX_ELISION_NP, | |
114 | PTHREAD_MUTEX_TIMED_NO_ELISION_NP = | |
115 | PTHREAD_MUTEX_TIMED_NP | PTHREAD_MUTEX_NO_ELISION_NP, | |
1bcfb5a5 | 116 | }; |
5bd8a249 | 117 | #define PTHREAD_MUTEX_PSHARED_BIT 128 |
f17efcb4 | 118 | |
403b4feb SL |
119 | /* See concurrency notes regarding __kind in struct __pthread_mutex_s |
120 | in sysdeps/nptl/bits/thread-shared-types.h. */ | |
ae1ad3ae | 121 | #define PTHREAD_MUTEX_TYPE(m) \ |
403b4feb | 122 | (atomic_load_relaxed (&((m)->__data.__kind)) & 127) |
e8c659d7 AK |
123 | /* Don't include NO_ELISION, as that type is always the same |
124 | as the underlying lock type. */ | |
b023e4ca | 125 | #define PTHREAD_MUTEX_TYPE_ELISION(m) \ |
403b4feb SL |
126 | (atomic_load_relaxed (&((m)->__data.__kind)) \ |
127 | & (127 | PTHREAD_MUTEX_ELISION_NP)) | |
5bd8a249 UD |
128 | |
129 | #if LLL_PRIVATE == 0 && LLL_SHARED == 128 | |
130 | # define PTHREAD_MUTEX_PSHARED(m) \ | |
403b4feb | 131 | (atomic_load_relaxed (&((m)->__data.__kind)) & 128) |
5bd8a249 UD |
132 | #else |
133 | # define PTHREAD_MUTEX_PSHARED(m) \ | |
403b4feb SL |
134 | ((atomic_load_relaxed (&((m)->__data.__kind)) & 128) \ |
135 | ? LLL_SHARED : LLL_PRIVATE) | |
5bd8a249 UD |
136 | #endif |
137 | ||
138 | /* The kernel when waking robust mutexes on exit never uses | |
139 | FUTEX_PRIVATE_FLAG FUTEX_WAKE. */ | |
140 | #define PTHREAD_ROBUST_MUTEX_PSHARED(m) LLL_SHARED | |
ae1ad3ae | 141 | |
f17efcb4 UD |
142 | /* Ceiling in __data.__lock. __data.__lock is signed, so don't |
143 | use the MSB bit in there, but in the mask also include that bit, | |
144 | so that the compiler can optimize & PTHREAD_MUTEX_PRIO_CEILING_MASK | |
145 | masking if the value is then shifted down by | |
146 | PTHREAD_MUTEX_PRIO_CEILING_SHIFT. */ | |
147 | #define PTHREAD_MUTEX_PRIO_CEILING_SHIFT 19 | |
148 | #define PTHREAD_MUTEX_PRIO_CEILING_MASK 0xfff80000 | |
1bcfb5a5 UD |
149 | |
150 | ||
151 | /* Flags in mutex attr. */ | |
a5f2bd86 RM |
152 | #define PTHREAD_MUTEXATTR_PROTOCOL_SHIFT 28 |
153 | #define PTHREAD_MUTEXATTR_PROTOCOL_MASK 0x30000000 | |
f17efcb4 UD |
154 | #define PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT 12 |
155 | #define PTHREAD_MUTEXATTR_PRIO_CEILING_MASK 0x00fff000 | |
a5f2bd86 RM |
156 | #define PTHREAD_MUTEXATTR_FLAG_ROBUST 0x40000000 |
157 | #define PTHREAD_MUTEXATTR_FLAG_PSHARED 0x80000000 | |
1bcfb5a5 | 158 | #define PTHREAD_MUTEXATTR_FLAG_BITS \ |
a5f2bd86 RM |
159 | (PTHREAD_MUTEXATTR_FLAG_ROBUST | PTHREAD_MUTEXATTR_FLAG_PSHARED \ |
160 | | PTHREAD_MUTEXATTR_PROTOCOL_MASK | PTHREAD_MUTEXATTR_PRIO_CEILING_MASK) | |
1bcfb5a5 UD |
161 | |
162 | ||
cc25c8b4 TR |
163 | /* For the following, see pthread_rwlock_common.c. */ |
164 | #define PTHREAD_RWLOCK_WRPHASE 1 | |
165 | #define PTHREAD_RWLOCK_WRLOCKED 2 | |
166 | #define PTHREAD_RWLOCK_RWAITING 4 | |
167 | #define PTHREAD_RWLOCK_READER_SHIFT 3 | |
168 | #define PTHREAD_RWLOCK_READER_OVERFLOW ((unsigned int) 1 \ | |
169 | << (sizeof (unsigned int) * 8 - 1)) | |
170 | #define PTHREAD_RWLOCK_WRHANDOVER ((unsigned int) 1 \ | |
171 | << (sizeof (unsigned int) * 8 - 1)) | |
172 | #define PTHREAD_RWLOCK_FUTEX_USED 2 | |
546346b6 UD |
173 | |
174 | ||
683040c3 UD |
175 | /* Bits used in robust mutex implementation. */ |
176 | #define FUTEX_WAITERS 0x80000000 | |
177 | #define FUTEX_OWNER_DIED 0x40000000 | |
2035d91c | 178 | #define FUTEX_TID_MASK 0x3fffffff |
683040c3 UD |
179 | |
180 | ||
63668b70 TR |
181 | /* pthread_once definitions. See __pthread_once for how these are used. */ |
182 | #define __PTHREAD_ONCE_INPROGRESS 1 | |
183 | #define __PTHREAD_ONCE_DONE 2 | |
184 | #define __PTHREAD_ONCE_FORK_GEN_INCR 4 | |
185 | ||
ce7528f6 AZ |
186 | /* Attribute to indicate thread creation was issued from C11 thrd_create. */ |
187 | #define ATTR_C11_THREAD ((void*)(uintptr_t)-1) | |
188 | ||
63668b70 | 189 | |
ed19993b TR |
190 | /* Condition variable definitions. See __pthread_cond_wait_common. |
191 | Need to be defined here so there is one place from which | |
192 | nptl_lock_constants can grab them. */ | |
193 | #define __PTHREAD_COND_CLOCK_MONOTONIC_MASK 2 | |
194 | #define __PTHREAD_COND_SHARED_MASK 1 | |
195 | ||
196 | ||
76a50749 UD |
197 | /* Internal variables. */ |
198 | ||
199 | ||
e903a713 | 200 | /* Default pthread attributes. */ |
8c1c0da3 FW |
201 | extern union pthread_attr_transparent __default_pthread_attr; |
202 | libc_hidden_proto (__default_pthread_attr) | |
203 | extern int __default_pthread_attr_lock; | |
204 | libc_hidden_proto (__default_pthread_attr_lock) | |
205 | /* Called from __libc_freeres to deallocate the default attribute. */ | |
c79a31fb | 206 | extern void __default_pthread_attr_freeres (void) attribute_hidden; |
76a50749 UD |
207 | |
208 | /* Size and alignment of static TLS block. */ | |
209 | extern size_t __static_tls_size attribute_hidden; | |
bc6389ad | 210 | extern size_t __static_tls_align_m1 attribute_hidden; |
76a50749 | 211 | |
76a50749 UD |
212 | /* Attribute handling. */ |
213 | extern struct pthread_attr *__attr_list attribute_hidden; | |
e51deae7 | 214 | extern int __attr_list_lock attribute_hidden; |
76a50749 | 215 | |
76a50749 UD |
216 | /* Concurrency handling. */ |
217 | extern int __concurrency_level attribute_hidden; | |
218 | ||
219 | /* Thread-local data key handling. */ | |
fa9a4ff0 | 220 | extern struct pthread_key_struct __pthread_keys[PTHREAD_KEYS_MAX]; |
a91bf4e0 | 221 | libc_hidden_proto (__pthread_keys) |
76a50749 | 222 | |
47202270 | 223 | /* Number of threads running. */ |
43fe356d FW |
224 | extern unsigned int __nptl_nthreads; |
225 | libc_hidden_proto (__nptl_nthreads) | |
47202270 | 226 | |
0f6699ea | 227 | #ifndef __ASSUME_SET_ROBUST_LIST |
442e8a40 FW |
228 | /* True if the set_robust_list system call works. Initialized in |
229 | __tls_init_tp. */ | |
230 | extern bool __nptl_set_robust_list_avail; | |
231 | rtld_hidden_proto (__nptl_set_robust_list_avail) | |
0f6699ea UD |
232 | #endif |
233 | ||
f17efcb4 | 234 | /* Thread Priority Protection. */ |
798cacde FW |
235 | extern int __sched_fifo_min_prio; |
236 | libc_hidden_proto (__sched_fifo_min_prio) | |
237 | extern int __sched_fifo_max_prio; | |
238 | libc_hidden_proto (__sched_fifo_max_prio) | |
239 | extern void __init_sched_fifo_prio (void); | |
240 | libc_hidden_proto (__init_sched_fifo_prio) | |
241 | extern int __pthread_tpp_change_priority (int prev_prio, int new_prio); | |
242 | libc_hidden_proto (__pthread_tpp_change_priority) | |
243 | extern int __pthread_current_priority (void); | |
244 | libc_hidden_proto (__pthread_current_priority) | |
f17efcb4 | 245 | |
d2af73a3 FW |
246 | /* This will not catch all invalid descriptors but is better than |
247 | nothing. And if the test triggers the thread descriptor is | |
248 | guaranteed to be invalid. */ | |
249 | #define INVALID_TD_P(pd) __builtin_expect ((pd)->tid <= 0, 0) | |
250 | #define INVALID_NOT_TERMINATED_TD_P(pd) __builtin_expect ((pd)->tid < 0, 0) | |
76a50749 UD |
251 | |
252 | /* Cancellation test. */ | |
253 | #define CANCELLATION_P(self) \ | |
254 | do { \ | |
255 | int cancelhandling = THREAD_GETMEM (self, cancelhandling); \ | |
256 | if (CANCEL_ENABLED_AND_CANCELED (cancelhandling)) \ | |
257 | { \ | |
258 | THREAD_SETMEM (self, result, PTHREAD_CANCELED); \ | |
9ae0909b | 259 | __do_cancel (); \ |
76a50749 UD |
260 | } \ |
261 | } while (0) | |
262 | ||
6efd4814 UD |
263 | |
264 | extern void __pthread_unwind (__pthread_unwind_buf_t *__buf) | |
265 | __cleanup_fct_attribute __attribute ((__noreturn__)) | |
ce9f10f7 | 266 | #if !defined SHARED && !IS_IN (libpthread) |
6efd4814 UD |
267 | weak_function |
268 | #endif | |
269 | ; | |
1d95b035 | 270 | libc_hidden_proto (__pthread_unwind) |
da0c02ee UD |
271 | extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf) |
272 | __cleanup_fct_attribute __attribute ((__noreturn__)) | |
273 | #ifndef SHARED | |
274 | weak_function | |
275 | #endif | |
276 | ; | |
1d95b035 FW |
277 | /* NB: No hidden proto for __pthread_unwind_next: inside glibc, the |
278 | legacy unwinding mechanism is used. */ | |
279 | ||
da0c02ee UD |
280 | extern void __pthread_register_cancel (__pthread_unwind_buf_t *__buf) |
281 | __cleanup_fct_attribute; | |
3ec8b1c7 | 282 | libc_hidden_proto (__pthread_register_cancel) |
da0c02ee UD |
283 | extern void __pthread_unregister_cancel (__pthread_unwind_buf_t *__buf) |
284 | __cleanup_fct_attribute; | |
3ec8b1c7 | 285 | libc_hidden_proto (__pthread_unregister_cancel) |
6efd4814 UD |
286 | |
287 | /* Called when a thread reacts on a cancellation request. */ | |
288 | static inline void | |
dd9423a6 | 289 | __attribute ((noreturn, always_inline)) |
6efd4814 UD |
290 | __do_cancel (void) |
291 | { | |
292 | struct pthread *self = THREAD_SELF; | |
293 | ||
294 | /* Make sure we get no more cancellations. */ | |
295 | THREAD_ATOMIC_BIT_SET (self, cancelhandling, EXITING_BIT); | |
296 | ||
297 | __pthread_unwind ((__pthread_unwind_buf_t *) | |
298 | THREAD_GETMEM (self, cleanup_jmp_buf)); | |
299 | } | |
300 | ||
301 | ||
76a50749 UD |
302 | /* Internal prototypes. */ |
303 | ||
76a50749 UD |
304 | /* Deallocate a thread's stack after optionally making sure the thread |
305 | descriptor is still valid. */ | |
8fbb33b3 FW |
306 | extern void __nptl_free_tcb (struct pthread *pd); |
307 | libc_hidden_proto (__nptl_free_tcb) | |
76a50749 | 308 | |
2dd87703 FW |
309 | /* Change the permissions of a thread stack. Called from |
310 | _dl_make_stacks_executable and pthread_create. */ | |
311 | int | |
312 | __nptl_change_stack_perm (struct pthread *pd); | |
313 | rtld_hidden_proto (__nptl_change_stack_perm) | |
54ee14b3 | 314 | |
76a50749 UD |
315 | /* longjmp handling. */ |
316 | extern void __pthread_cleanup_upto (__jmp_buf target, char *targetframe); | |
4647ce82 | 317 | libc_hidden_proto (__pthread_cleanup_upto) |
76a50749 UD |
318 | |
319 | ||
320 | /* Functions with versioned interfaces. */ | |
321 | extern int __pthread_create_2_1 (pthread_t *newthread, | |
322 | const pthread_attr_t *attr, | |
323 | void *(*start_routine) (void *), void *arg); | |
324 | extern int __pthread_create_2_0 (pthread_t *newthread, | |
325 | const pthread_attr_t *attr, | |
326 | void *(*start_routine) (void *), void *arg); | |
3699ef99 FW |
327 | extern int __pthread_attr_init (pthread_attr_t *attr); |
328 | libc_hidden_proto (__pthread_attr_init) | |
76a50749 UD |
329 | extern int __pthread_attr_init_2_0 (pthread_attr_t *attr); |
330 | ||
a78e5979 FW |
331 | /* Part of the legacy thread events interface (which has been |
332 | superseded by PTRACE_O_TRACECLONE). This can be set by the | |
333 | debugger before initialization is complete. */ | |
334 | extern bool __nptl_initial_report_events; | |
335 | rtld_hidden_proto (__nptl_initial_report_events) | |
76a50749 UD |
336 | |
337 | /* Event handlers for libthread_db interface. */ | |
fa9a4ff0 RM |
338 | extern void __nptl_create_event (void); |
339 | extern void __nptl_death_event (void); | |
340 | hidden_proto (__nptl_create_event) | |
341 | hidden_proto (__nptl_death_event) | |
76a50749 | 342 | |
64786a70 ST |
343 | /* The fork generation counter, defined in libpthread. */ |
344 | extern unsigned long int __fork_generation attribute_hidden; | |
345 | ||
346 | /* Pointer to the fork generation counter in the thread library. */ | |
347 | extern unsigned long int *__fork_generation_pointer attribute_hidden; | |
348 | ||
2c1094bd | 349 | extern size_t __pthread_get_minstack (const pthread_attr_t *attr); |
76a50749 UD |
350 | |
351 | /* Namespace save aliases. */ | |
8454830b UD |
352 | extern int __pthread_getschedparam (pthread_t thread_id, int *policy, |
353 | struct sched_param *param); | |
354 | extern int __pthread_setschedparam (pthread_t thread_id, int policy, | |
355 | const struct sched_param *param); | |
76a50749 | 356 | extern int __pthread_mutex_init (pthread_mutex_t *__mutex, |
a784e502 | 357 | const pthread_mutexattr_t *__mutexattr); |
27a44822 | 358 | libc_hidden_proto (__pthread_mutex_init) |
76a50749 | 359 | extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex); |
27a44822 | 360 | libc_hidden_proto (__pthread_mutex_destroy) |
76a50749 | 361 | extern int __pthread_mutex_trylock (pthread_mutex_t *_mutex); |
a2b0f2e1 | 362 | libc_hidden_proto (__pthread_mutex_trylock) |
76a50749 | 363 | extern int __pthread_mutex_lock (pthread_mutex_t *__mutex); |
27a44822 | 364 | libc_hidden_proto (__pthread_mutex_lock) |
fa872e1b AZ |
365 | extern int __pthread_mutex_timedlock (pthread_mutex_t *__mutex, |
366 | const struct timespec *__abstime); | |
69431c9a | 367 | extern int __pthread_mutex_cond_lock (pthread_mutex_t *__mutex) |
83b09837 | 368 | attribute_hidden; |
b0948ffd | 369 | extern void __pthread_mutex_cond_lock_adjust (pthread_mutex_t *__mutex) |
83b09837 | 370 | attribute_hidden; |
76a50749 | 371 | extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex); |
27a44822 | 372 | libc_hidden_proto (__pthread_mutex_unlock) |
b758b9cb | 373 | extern int __pthread_mutex_unlock_usercnt (pthread_mutex_t *__mutex, |
27a44822 FW |
374 | int __decr); |
375 | libc_hidden_proto (__pthread_mutex_unlock_usercnt) | |
76a50749 | 376 | extern int __pthread_mutexattr_init (pthread_mutexattr_t *attr); |
f44c9a24 | 377 | libc_hidden_proto (__pthread_mutexattr_init) |
76a50749 UD |
378 | extern int __pthread_mutexattr_destroy (pthread_mutexattr_t *attr); |
379 | extern int __pthread_mutexattr_settype (pthread_mutexattr_t *attr, int kind); | |
f44c9a24 | 380 | libc_hidden_proto (__pthread_mutexattr_settype) |
8454830b | 381 | extern int __pthread_attr_destroy (pthread_attr_t *attr); |
3699ef99 | 382 | libc_hidden_proto (__pthread_attr_destroy) |
8454830b UD |
383 | extern int __pthread_attr_getdetachstate (const pthread_attr_t *attr, |
384 | int *detachstate); | |
385 | extern int __pthread_attr_setdetachstate (pthread_attr_t *attr, | |
386 | int detachstate); | |
387 | extern int __pthread_attr_getinheritsched (const pthread_attr_t *attr, | |
388 | int *inherit); | |
389 | extern int __pthread_attr_setinheritsched (pthread_attr_t *attr, int inherit); | |
390 | extern int __pthread_attr_getschedparam (const pthread_attr_t *attr, | |
391 | struct sched_param *param); | |
392 | extern int __pthread_attr_setschedparam (pthread_attr_t *attr, | |
393 | const struct sched_param *param); | |
394 | extern int __pthread_attr_getschedpolicy (const pthread_attr_t *attr, | |
395 | int *policy); | |
396 | extern int __pthread_attr_setschedpolicy (pthread_attr_t *attr, int policy); | |
397 | extern int __pthread_attr_getscope (const pthread_attr_t *attr, int *scope); | |
398 | extern int __pthread_attr_setscope (pthread_attr_t *attr, int scope); | |
a784e502 | 399 | extern int __pthread_attr_getstackaddr (const pthread_attr_t *__restrict |
76a50749 UD |
400 | __attr, void **__restrict __stackaddr); |
401 | extern int __pthread_attr_setstackaddr (pthread_attr_t *__attr, | |
402 | void *__stackaddr); | |
a784e502 | 403 | extern int __pthread_attr_getstacksize (const pthread_attr_t *__restrict |
76a50749 UD |
404 | __attr, |
405 | size_t *__restrict __stacksize); | |
406 | extern int __pthread_attr_setstacksize (pthread_attr_t *__attr, | |
407 | size_t __stacksize); | |
a784e502 | 408 | extern int __pthread_attr_getstack (const pthread_attr_t *__restrict __attr, |
76a50749 UD |
409 | void **__restrict __stackaddr, |
410 | size_t *__restrict __stacksize); | |
411 | extern int __pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr, | |
412 | size_t __stacksize); | |
1979819d FW |
413 | int __pthread_attr_setaffinity_np (pthread_attr_t *, size_t, const cpu_set_t *); |
414 | libc_hidden_proto (__pthread_attr_setaffinity_np) | |
dd05e154 FW |
415 | extern __typeof (pthread_getattr_default_np) __pthread_getattr_default_np; |
416 | libpthread_hidden_proto (__pthread_getattr_default_np) | |
76a50749 | 417 | extern int __pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock, |
a784e502 | 418 | const pthread_rwlockattr_t *__restrict |
76a50749 UD |
419 | __attr); |
420 | extern int __pthread_rwlock_destroy (pthread_rwlock_t *__rwlock); | |
421 | extern int __pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock); | |
eb29dcde | 422 | libc_hidden_proto (__pthread_rwlock_rdlock) |
76a50749 UD |
423 | extern int __pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock); |
424 | extern int __pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock); | |
eb29dcde | 425 | libc_hidden_proto (__pthread_rwlock_wrlock) |
76a50749 UD |
426 | extern int __pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock); |
427 | extern int __pthread_rwlock_unlock (pthread_rwlock_t *__rwlock); | |
8454830b | 428 | extern int __pthread_cond_broadcast (pthread_cond_t *cond); |
08129b15 | 429 | libc_hidden_proto (__pthread_cond_broadcast) |
8454830b | 430 | extern int __pthread_cond_destroy (pthread_cond_t *cond); |
dc6cfdc9 | 431 | libc_hidden_proto (__pthread_cond_destroy) |
8454830b UD |
432 | extern int __pthread_cond_init (pthread_cond_t *cond, |
433 | const pthread_condattr_t *cond_attr); | |
ad96df2c | 434 | libc_hidden_proto (__pthread_cond_init) |
8454830b | 435 | extern int __pthread_cond_signal (pthread_cond_t *cond); |
08129b15 | 436 | libc_hidden_proto (__pthread_cond_signal) |
8454830b | 437 | extern int __pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex); |
08129b15 | 438 | libc_hidden_proto (__pthread_cond_wait) |
4a14cb87 LM |
439 | |
440 | #if __TIMESIZE == 64 | |
441 | # define __pthread_clockjoin_np64 __pthread_clockjoin_np | |
442 | # define __pthread_timedjoin_np64 __pthread_timedjoin_np | |
323592fd LM |
443 | # define __pthread_cond_timedwait64 __pthread_cond_timedwait |
444 | # define __pthread_cond_clockwait64 __pthread_cond_clockwait | |
3102e28b LM |
445 | # define __pthread_rwlock_clockrdlock64 __pthread_rwlock_clockrdlock |
446 | # define __pthread_rwlock_clockwrlock64 __pthread_rwlock_clockwrlock | |
447 | # define __pthread_rwlock_timedrdlock64 __pthread_rwlock_timedrdlock | |
448 | # define __pthread_rwlock_timedwrlock64 __pthread_rwlock_timedwrlock | |
29e9874a LM |
449 | # define __pthread_mutex_clocklock64 __pthread_mutex_clocklock |
450 | # define __pthread_mutex_timedlock64 __pthread_mutex_timedlock | |
4a14cb87 LM |
451 | #else |
452 | extern int __pthread_clockjoin_np64 (pthread_t threadid, void **thread_return, | |
453 | clockid_t clockid, | |
454 | const struct __timespec64 *abstime); | |
ddd4a2d3 | 455 | libc_hidden_proto (__pthread_clockjoin_np64) |
4a14cb87 LM |
456 | extern int __pthread_timedjoin_np64 (pthread_t threadid, void **thread_return, |
457 | const struct __timespec64 *abstime); | |
ddd4a2d3 | 458 | libc_hidden_proto (__pthread_timedjoin_np64) |
323592fd LM |
459 | extern int __pthread_cond_timedwait64 (pthread_cond_t *cond, |
460 | pthread_mutex_t *mutex, | |
461 | const struct __timespec64 *abstime); | |
08129b15 | 462 | libc_hidden_proto (__pthread_cond_timedwait64) |
323592fd LM |
463 | extern int __pthread_cond_clockwait64 (pthread_cond_t *cond, |
464 | pthread_mutex_t *mutex, | |
465 | clockid_t clockid, | |
466 | const struct __timespec64 *abstime); | |
08129b15 | 467 | libc_hidden_proto (__pthread_cond_clockwait64) |
3102e28b LM |
468 | extern int __pthread_rwlock_clockrdlock64 (pthread_rwlock_t *rwlock, |
469 | clockid_t clockid, | |
470 | const struct __timespec64 *abstime); | |
0ace9b19 | 471 | libc_hidden_proto (__pthread_rwlock_clockrdlock64) |
3102e28b LM |
472 | extern int __pthread_rwlock_clockwrlock64 (pthread_rwlock_t *rwlock, |
473 | clockid_t clockid, | |
474 | const struct __timespec64 *abstime); | |
2cf5b43b | 475 | libc_hidden_proto (__pthread_rwlock_clockwrlock64) |
3102e28b LM |
476 | extern int __pthread_rwlock_timedrdlock64 (pthread_rwlock_t *rwlock, |
477 | const struct __timespec64 *abstime); | |
2392feb1 | 478 | libc_hidden_proto (__pthread_rwlock_timedrdlock64) |
3102e28b LM |
479 | extern int __pthread_rwlock_timedwrlock64 (pthread_rwlock_t *rwlock, |
480 | const struct __timespec64 *abstime); | |
e7d2d48e | 481 | libc_hidden_proto (__pthread_rwlock_timedwrlock64) |
29e9874a LM |
482 | extern int __pthread_mutex_clocklock64 (pthread_mutex_t *mutex, |
483 | clockid_t clockid, | |
484 | const struct __timespec64 *abstime); | |
4372dc7e | 485 | libc_hidden_proto (__pthread_mutex_clocklock64) |
29e9874a LM |
486 | extern int __pthread_mutex_timedlock64 (pthread_mutex_t *mutex, |
487 | const struct __timespec64 *abstime); | |
4372dc7e | 488 | libc_hidden_proto (__pthread_mutex_timedlock64) |
4a14cb87 LM |
489 | #endif |
490 | ||
b5facfda UD |
491 | extern int __pthread_cond_timedwait (pthread_cond_t *cond, |
492 | pthread_mutex_t *mutex, | |
493 | const struct timespec *abstime); | |
08129b15 | 494 | libc_hidden_proto (__pthread_cond_timedwait) |
afe4de7d MC |
495 | extern int __pthread_cond_clockwait (pthread_cond_t *cond, |
496 | pthread_mutex_t *mutex, | |
497 | clockid_t clockid, | |
498 | const struct timespec *abstime) | |
499 | __nonnull ((1, 2, 4)); | |
08129b15 | 500 | libc_hidden_proto (__pthread_cond_clockwait) |
4372dc7e FW |
501 | |
502 | extern int __pthread_mutex_clocklock (pthread_mutex_t *mutex, | |
503 | clockid_t clockid, | |
504 | const struct timespec *abstime); | |
505 | libc_hidden_proto (__pthread_mutex_clocklock) | |
506 | extern int __pthread_mutex_timedlock (pthread_mutex_t *mutex, | |
507 | const struct timespec *abstime); | |
508 | libc_hidden_proto (__pthread_mutex_timedlock) | |
509 | ||
8454830b UD |
510 | extern int __pthread_condattr_destroy (pthread_condattr_t *attr); |
511 | extern int __pthread_condattr_init (pthread_condattr_t *attr); | |
76a50749 | 512 | extern int __pthread_key_create (pthread_key_t *key, void (*destr) (void *)); |
e4036b1c | 513 | libc_hidden_proto (__pthread_key_create) |
fa872e1b | 514 | extern int __pthread_key_delete (pthread_key_t key); |
9ce44f46 | 515 | libc_hidden_proto (__pthread_key_delete) |
76a50749 | 516 | extern void *__pthread_getspecific (pthread_key_t key); |
aae43acf | 517 | libc_hidden_proto (__pthread_getspecific) |
76a50749 | 518 | extern int __pthread_setspecific (pthread_key_t key, const void *value); |
64a8990b | 519 | libc_hidden_proto (__pthread_setspecific) |
76a50749 UD |
520 | extern int __pthread_once (pthread_once_t *once_control, |
521 | void (*init_routine) (void)); | |
3fec7f18 | 522 | libc_hidden_proto (__pthread_once) |
76a50749 UD |
523 | extern int __pthread_atfork (void (*prepare) (void), void (*parent) (void), |
524 | void (*child) (void)); | |
8454830b UD |
525 | extern pthread_t __pthread_self (void); |
526 | extern int __pthread_equal (pthread_t thread1, pthread_t thread2); | |
fa872e1b | 527 | extern int __pthread_detach (pthread_t th); |
df65f897 | 528 | libc_hidden_proto (__pthread_detach) |
09efc3ba | 529 | extern int __pthread_kill (pthread_t threadid, int signo); |
356fa562 | 530 | extern void __pthread_exit (void *value) __attribute__ ((__noreturn__)); |
c62cef02 | 531 | libc_hidden_proto (__pthread_exit) |
fa872e1b | 532 | extern int __pthread_join (pthread_t threadid, void **thread_return); |
ddd4a2d3 | 533 | libc_hidden_proto (__pthread_join) |
09efc3ba | 534 | extern int __pthread_setcanceltype (int type, int *oldtype); |
75376a3f | 535 | libc_hidden_proto (__pthread_setcanceltype) |
47677f2e | 536 | extern void __pthread_testcancel (void); |
0197c1bc | 537 | libc_hidden_proto (__pthread_testcancel) |
69ca4b54 | 538 | extern int __pthread_clockjoin_ex (pthread_t, void **, clockid_t, |
4a14cb87 | 539 | const struct __timespec64 *, bool) |
69ca4b54 | 540 | attribute_hidden; |
2f6fa801 AZ |
541 | extern int __pthread_sigmask (int, const sigset_t *, sigset_t *); |
542 | libc_hidden_proto (__pthread_sigmask); | |
69ca4b54 | 543 | |
9ae0909b | 544 | |
ce9f10f7 | 545 | #if IS_IN (libpthread) |
4d17e683 | 546 | hidden_proto (__pthread_rwlock_unlock) |
4d17e683 AS |
547 | #endif |
548 | ||
997256dd UD |
549 | extern int __pthread_cond_broadcast_2_0 (pthread_cond_2_0_t *cond); |
550 | extern int __pthread_cond_destroy_2_0 (pthread_cond_2_0_t *cond); | |
551 | extern int __pthread_cond_init_2_0 (pthread_cond_2_0_t *cond, | |
05df18c3 | 552 | const pthread_condattr_t *cond_attr); |
997256dd UD |
553 | extern int __pthread_cond_signal_2_0 (pthread_cond_2_0_t *cond); |
554 | extern int __pthread_cond_timedwait_2_0 (pthread_cond_2_0_t *cond, | |
05df18c3 UD |
555 | pthread_mutex_t *mutex, |
556 | const struct timespec *abstime); | |
997256dd | 557 | extern int __pthread_cond_wait_2_0 (pthread_cond_2_0_t *cond, |
05df18c3 UD |
558 | pthread_mutex_t *mutex); |
559 | ||
439ff07b UD |
560 | extern int __pthread_getaffinity_np (pthread_t th, size_t cpusetsize, |
561 | cpu_set_t *cpuset); | |
52302bc2 | 562 | libc_hidden_proto (__pthread_getaffinity_np) |
73e9ae88 | 563 | |
ec41af45 FW |
564 | /* Special internal version of pthread_attr_setsigmask_np which does |
565 | not filter out internal signals from *SIGMASK. This can be used to | |
566 | launch threads with internal signals blocked. */ | |
567 | extern int __pthread_attr_setsigmask_internal (pthread_attr_t *attr, | |
568 | const sigset_t *sigmask); | |
569 | libc_hidden_proto (__pthread_attr_setsigmask_internal) | |
570 | ||
571 | extern __typeof (pthread_attr_getsigmask_np) __pthread_attr_getsigmask_np; | |
572 | libc_hidden_proto (__pthread_attr_getsigmask_np) | |
573 | ||
09efc3ba | 574 | /* Special versions which use non-exported functions. */ |
73e9ae88 | 575 | extern void __pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer, |
1f2e5bfe FW |
576 | void (*routine) (void *), void *arg); |
577 | libc_hidden_proto (__pthread_cleanup_push) | |
09efc3ba | 578 | |
203c1a89 MS |
579 | /* Replace cleanup macros defined in <pthread.h> with internal |
580 | versions that don't depend on unwind info and better support | |
581 | cancellation. */ | |
582 | # undef pthread_cleanup_push | |
583 | # define pthread_cleanup_push(routine,arg) \ | |
584 | { struct _pthread_cleanup_buffer _buffer; \ | |
585 | __pthread_cleanup_push (&_buffer, (routine), (arg)); | |
586 | ||
73e9ae88 | 587 | extern void __pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer, |
1f2e5bfe FW |
588 | int execute); |
589 | libc_hidden_proto (__pthread_cleanup_pop) | |
203c1a89 MS |
590 | # undef pthread_cleanup_pop |
591 | # define pthread_cleanup_pop(execute) \ | |
592 | __pthread_cleanup_pop (&_buffer, (execute)); } | |
f0419e6a | 593 | |
1f2e5bfe | 594 | #if defined __EXCEPTIONS && !defined __cplusplus |
f0419e6a JJ |
595 | /* Structure to hold the cleanup handler information. */ |
596 | struct __pthread_cleanup_combined_frame | |
597 | { | |
598 | void (*__cancel_routine) (void *); | |
599 | void *__cancel_arg; | |
600 | int __do_it; | |
601 | struct _pthread_cleanup_buffer __buffer; | |
602 | }; | |
603 | ||
604 | /* Special cleanup macros which register cleanup both using | |
605 | __pthread_cleanup_{push,pop} and using cleanup attribute. This is needed | |
606 | for pthread_once, so that it supports both throwing exceptions from the | |
607 | pthread_once callback (only cleanup attribute works there) and cancellation | |
608 | of the thread running the callback if the callback or some routines it | |
609 | calls don't have unwind information. */ | |
610 | ||
611 | static __always_inline void | |
612 | __pthread_cleanup_combined_routine (struct __pthread_cleanup_combined_frame | |
613 | *__frame) | |
614 | { | |
615 | if (__frame->__do_it) | |
616 | { | |
617 | __frame->__cancel_routine (__frame->__cancel_arg); | |
618 | __frame->__do_it = 0; | |
619 | __pthread_cleanup_pop (&__frame->__buffer, 0); | |
620 | } | |
621 | } | |
622 | ||
623 | static inline void | |
624 | __pthread_cleanup_combined_routine_voidptr (void *__arg) | |
625 | { | |
626 | struct __pthread_cleanup_combined_frame *__frame | |
627 | = (struct __pthread_cleanup_combined_frame *) __arg; | |
628 | if (__frame->__do_it) | |
629 | { | |
630 | __frame->__cancel_routine (__frame->__cancel_arg); | |
631 | __frame->__do_it = 0; | |
632 | } | |
633 | } | |
634 | ||
1f2e5bfe | 635 | # define pthread_cleanup_combined_push(routine, arg) \ |
f0419e6a JJ |
636 | do { \ |
637 | void (*__cancel_routine) (void *) = (routine); \ | |
638 | struct __pthread_cleanup_combined_frame __clframe \ | |
639 | __attribute__ ((__cleanup__ (__pthread_cleanup_combined_routine))) \ | |
640 | = { .__cancel_routine = __cancel_routine, .__cancel_arg = (arg), \ | |
641 | .__do_it = 1 }; \ | |
642 | __pthread_cleanup_push (&__clframe.__buffer, \ | |
643 | __pthread_cleanup_combined_routine_voidptr, \ | |
644 | &__clframe); | |
645 | ||
1f2e5bfe | 646 | # define pthread_cleanup_combined_pop(execute) \ |
f0419e6a JJ |
647 | __pthread_cleanup_pop (&__clframe.__buffer, 0); \ |
648 | __clframe.__do_it = 0; \ | |
649 | if (execute) \ | |
650 | __cancel_routine (__clframe.__cancel_arg); \ | |
651 | } while (0) | |
652 | ||
1f2e5bfe | 653 | #endif /* __EXCEPTIONS && !defined __cplusplus */ |
76a50749 | 654 | |
73e9ae88 UD |
655 | extern void __pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer, |
656 | void (*routine) (void *), void *arg); | |
657 | extern void __pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer, | |
658 | int execute); | |
659 | ||
6efd4814 UD |
660 | /* Old cleanup interfaces, still used in libc.so. */ |
661 | extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer, | |
6f8326ca | 662 | void (*routine) (void *), void *arg); |
6efd4814 | 663 | extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer, |
6f8326ca | 664 | int execute); |
6efd4814 | 665 | extern void _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer, |
6f8326ca | 666 | void (*routine) (void *), void *arg); |
6efd4814 | 667 | extern void _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer, |
6f8326ca | 668 | int execute); |
6efd4814 | 669 | |
2cfef0b0 FW |
670 | extern void __nptl_deallocate_tsd (void); |
671 | libc_hidden_proto (__nptl_deallocate_tsd) | |
3fa21fd8 | 672 | |
486010a3 FW |
673 | void __nptl_setxid_sighandler (int sig, siginfo_t *si, void *ctx); |
674 | libc_hidden_proto (__nptl_setxid_sighandler) | |
ccd8de9a | 675 | extern int __nptl_setxid (struct xid_command *cmdp) attribute_hidden; |
2edb61e3 | 676 | |
df94b641 UD |
677 | extern void __wait_lookup_done (void) attribute_hidden; |
678 | ||
7538d461 FW |
679 | /* Allocates the extension space for ATTR. Returns an error code on |
680 | memory allocation failure, zero on success. If ATTR already has an | |
681 | extension space, this function does nothing. */ | |
682 | int __pthread_attr_extension (struct pthread_attr *attr) attribute_hidden | |
683 | __attribute_warn_unused_result__; | |
684 | ||
b639d0c9 UD |
685 | #ifdef SHARED |
686 | # define PTHREAD_STATIC_FN_REQUIRE(name) | |
687 | #else | |
688 | # define PTHREAD_STATIC_FN_REQUIRE(name) __asm (".globl " #name); | |
689 | #endif | |
690 | ||
331c6e8a FW |
691 | /* Make a deep copy of the attribute *SOURCE in *TARGET. *TARGET is |
692 | not assumed to have been initialized. Returns 0 on success, or a | |
693 | positive error code otherwise. */ | |
694 | int __pthread_attr_copy (pthread_attr_t *target, const pthread_attr_t *source); | |
695 | libc_hidden_proto (__pthread_attr_copy) | |
696 | ||
da1304bc SP |
697 | /* Returns 0 if POL is a valid scheduling policy. */ |
698 | static inline int | |
699 | check_sched_policy_attr (int pol) | |
700 | { | |
701 | if (pol == SCHED_OTHER || pol == SCHED_FIFO || pol == SCHED_RR) | |
702 | return 0; | |
703 | ||
704 | return EINVAL; | |
705 | } | |
706 | ||
707 | /* Returns 0 if PR is within the accepted range of priority values for | |
708 | the scheduling policy POL or EINVAL otherwise. */ | |
709 | static inline int | |
710 | check_sched_priority_attr (int pr, int pol) | |
711 | { | |
712 | int min = __sched_get_priority_min (pol); | |
713 | int max = __sched_get_priority_max (pol); | |
714 | ||
715 | if (min >= 0 && max >= 0 && pr >= min && pr <= max) | |
716 | return 0; | |
717 | ||
718 | return EINVAL; | |
719 | } | |
720 | ||
721 | /* Returns 0 if ST is a valid stack size for a thread stack and EINVAL | |
722 | otherwise. */ | |
723 | static inline int | |
724 | check_stacksize_attr (size_t st) | |
725 | { | |
726 | if (st >= PTHREAD_STACK_MIN) | |
727 | return 0; | |
728 | ||
729 | return EINVAL; | |
730 | } | |
731 | ||
72b3c6ee AZ |
732 | #define ASSERT_TYPE_SIZE(type, size) \ |
733 | _Static_assert (sizeof (type) == size, \ | |
734 | "sizeof (" #type ") != " #size) | |
735 | ||
736 | #define ASSERT_PTHREAD_INTERNAL_SIZE(type, internal) \ | |
a3aaa598 | 737 | _Static_assert (sizeof ((type) { { 0 } }).__size >= sizeof (internal),\ |
72b3c6ee AZ |
738 | "sizeof (" #type ".__size) < sizeof (" #internal ")") |
739 | ||
dff91cd4 AZ |
740 | #define ASSERT_PTHREAD_STRING(x) __STRING (x) |
741 | #define ASSERT_PTHREAD_INTERNAL_OFFSET(type, member, offset) \ | |
742 | _Static_assert (offsetof (type, member) == offset, \ | |
743 | "offset of " #member " field of " #type " != " \ | |
744 | ASSERT_PTHREAD_STRING (offset)) | |
71d260c1 AZ |
745 | #define ASSERT_PTHREAD_INTERNAL_MEMBER_SIZE(type, member, mtype) \ |
746 | _Static_assert (sizeof (((type) { 0 }).member) != 8, \ | |
747 | "sizeof (" #type "." #member ") != sizeof (" #mtype "))") | |
dff91cd4 | 748 | |
76a50749 | 749 | #endif /* pthreadP.h */ |