]>
Commit | Line | Data |
---|---|---|
8321ef15 | 1 | /* Definitions for thread-local data handling. Hurd version. |
2b778ceb | 2 | Copyright (C) 2003-2021 Free Software Foundation, Inc. |
8321ef15 RM |
3 | This file is part of the GNU C Library. |
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/>. */ |
8321ef15 RM |
18 | |
19 | #ifndef _TLS_H | |
20 | #define _TLS_H | |
21 | ||
83cd1420 | 22 | #ifndef __ASSEMBLER__ |
b0104b6f RM |
23 | |
24 | # include <stddef.h> | |
4fc81a77 | 25 | # include <stdint.h> |
69553a9b | 26 | # include <stdbool.h> |
4fc81a77 | 27 | # include <sysdep.h> |
b0104b6f RM |
28 | # include <mach/mig_errors.h> |
29 | # include <mach.h> | |
a5df0318 | 30 | # include <atomic.h> |
b0104b6f | 31 | |
8321ef15 | 32 | |
8321ef15 RM |
33 | /* This is the size of the initial TCB. */ |
34 | # define TLS_INIT_TCB_SIZE sizeof (tcbhead_t) | |
35 | ||
36 | /* Alignment requirements for the initial TCB. */ | |
37 | # define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t) | |
38 | ||
39 | /* This is the size of the TCB. */ | |
40 | # define TLS_TCB_SIZE TLS_INIT_TCB_SIZE /* XXX */ | |
41 | ||
42 | /* Alignment requirements for the TCB. */ | |
43 | # define TLS_TCB_ALIGN TLS_INIT_TCB_ALIGN /* XXX */ | |
44 | ||
b0104b6f RM |
45 | |
46 | /* Install the dtv pointer. The pointer passed is to the element with | |
47 | index -1 which contain the length. */ | |
48 | # define INSTALL_DTV(descr, dtvp) \ | |
49 | ((tcbhead_t *) (descr))->dtv = (dtvp) + 1 | |
50 | ||
51 | /* Return dtv of given thread descriptor. */ | |
52 | # define GET_DTV(descr) \ | |
53 | (((tcbhead_t *) (descr))->dtv) | |
54 | ||
a5df0318 ST |
55 | /* Global scope switch support. */ |
56 | #define THREAD_GSCOPE_IN_TCB 0 | |
57 | #define THREAD_GSCOPE_GLOBAL | |
58 | #define THREAD_GSCOPE_SET_FLAG() \ | |
59 | atomic_exchange_and_add_acq (&GL(dl_thread_gscope_count), 1) | |
60 | #define THREAD_GSCOPE_RESET_FLAG() \ | |
61 | do \ | |
62 | if (atomic_exchange_and_add_rel (&GL(dl_thread_gscope_count), -1) == 1) \ | |
bec41242 | 63 | lll_wake (GL(dl_thread_gscope_count), 0); \ |
a5df0318 ST |
64 | while (0) |
65 | #define THREAD_GSCOPE_WAIT() \ | |
66 | do \ | |
67 | { \ | |
68 | int count; \ | |
69 | atomic_write_barrier (); \ | |
70 | while ((count = GL(dl_thread_gscope_count))) \ | |
bec41242 | 71 | lll_wait (GL(dl_thread_gscope_count), count, 0); \ |
a5df0318 ST |
72 | } \ |
73 | while (0) | |
74 | ||
83cd1420 | 75 | #endif /* !ASSEMBLER */ |
8321ef15 | 76 | |
b0104b6f | 77 | |
8321ef15 | 78 | #endif /* tls.h */ |