]>
Commit | Line | Data |
---|---|---|
02a9f771 | 1 | /* Definition for thread-local data handling. NPTL/ARM version. |
2b778ceb | 2 | Copyright (C) 2005-2021 Free Software Foundation, Inc. |
02a9f771 DJ |
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 | |
ab84e3ff | 16 | License along with the GNU C Library. If not, see |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
02a9f771 | 18 | |
46f1d8a6 RM |
19 | #ifndef _ARM_NPTL_TLS_H |
20 | #define _ARM_NPTL_TLS_H 1 | |
02a9f771 DJ |
21 | |
22 | #include <dl-sysdep.h> | |
23 | ||
24 | #ifndef __ASSEMBLER__ | |
25 | # include <stdbool.h> | |
26 | # include <stddef.h> | |
27 | # include <stdint.h> | |
aca1daef | 28 | # include <dl-dtv.h> |
02a9f771 DJ |
29 | |
30 | #else /* __ASSEMBLER__ */ | |
31 | # include <tcb-offsets.h> | |
32 | #endif /* __ASSEMBLER__ */ | |
33 | ||
34 | ||
02a9f771 DJ |
35 | #ifndef __ASSEMBLER__ |
36 | ||
02a9f771 DJ |
37 | /* The TP points to the start of the thread blocks. */ |
38 | # define TLS_DTV_AT_TP 1 | |
498a2233 | 39 | # define TLS_TCB_AT_TP 0 |
02a9f771 DJ |
40 | |
41 | /* Get the thread descriptor definition. */ | |
42 | # include <nptl/descr.h> | |
43 | ||
44 | typedef struct | |
45 | { | |
46 | dtv_t *dtv; | |
47 | void *private; | |
48 | } tcbhead_t; | |
49 | ||
50 | /* This is the size of the initial TCB. */ | |
51 | # define TLS_INIT_TCB_SIZE sizeof (tcbhead_t) | |
52 | ||
53 | /* Alignment requirements for the initial TCB. */ | |
54 | # define TLS_INIT_TCB_ALIGN 16 | |
55 | ||
56 | /* This is the size of the TCB. */ | |
57 | # define TLS_TCB_SIZE sizeof (tcbhead_t) | |
58 | ||
59 | /* This is the size we need before TCB. */ | |
60 | # define TLS_PRE_TCB_SIZE sizeof (struct pthread) | |
61 | ||
62 | /* Alignment requirements for the TCB. */ | |
63 | # define TLS_TCB_ALIGN 16 | |
64 | ||
65 | /* Install the dtv pointer. The pointer passed is to the element with | |
66 | index -1 which contain the length. */ | |
67 | # define INSTALL_DTV(tcbp, dtvp) \ | |
68 | (((tcbhead_t *) (tcbp))->dtv = (dtvp) + 1) | |
69 | ||
70 | /* Install new dtv for current thread. */ | |
71 | # define INSTALL_NEW_DTV(dtv) \ | |
72 | (THREAD_DTV() = (dtv)) | |
73 | ||
74 | /* Return dtv of given thread descriptor. */ | |
75 | # define GET_DTV(tcbp) \ | |
76 | (((tcbhead_t *) (tcbp))->dtv) | |
77 | ||
08f41f04 RM |
78 | # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1 |
79 | ||
02a9f771 DJ |
80 | /* Return the address of the dtv for the current thread. */ |
81 | # define THREAD_DTV() \ | |
82 | (((tcbhead_t *) __builtin_thread_pointer ())->dtv) | |
83 | ||
84 | /* Return the thread descriptor for the current thread. */ | |
85 | # define THREAD_SELF \ | |
86 | ((struct pthread *)__builtin_thread_pointer () - 1) | |
87 | ||
88 | /* Magic for libthread_db to know how to do THREAD_SELF. */ | |
89 | # define DB_THREAD_SELF \ | |
90 | CONST_THREAD_AREA (32, sizeof (struct pthread)) | |
91 | ||
92 | /* Access to data in the thread descriptor is easy. */ | |
93 | #define THREAD_GETMEM(descr, member) \ | |
94 | descr->member | |
95 | #define THREAD_GETMEM_NC(descr, member, idx) \ | |
96 | descr->member[idx] | |
97 | #define THREAD_SETMEM(descr, member, value) \ | |
98 | descr->member = (value) | |
99 | #define THREAD_SETMEM_NC(descr, member, idx, value) \ | |
100 | descr->member[idx] = (value) | |
101 | ||
30efab51 | 102 | /* Get and set the global scope generation counter in struct pthread. */ |
a5df0318 | 103 | #define THREAD_GSCOPE_IN_TCB 1 |
30efab51 DJ |
104 | #define THREAD_GSCOPE_FLAG_UNUSED 0 |
105 | #define THREAD_GSCOPE_FLAG_USED 1 | |
106 | #define THREAD_GSCOPE_FLAG_WAIT 2 | |
107 | #define THREAD_GSCOPE_RESET_FLAG() \ | |
108 | do \ | |
109 | { int __res \ | |
110 | = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ | |
111 | THREAD_GSCOPE_FLAG_UNUSED); \ | |
112 | if (__res == THREAD_GSCOPE_FLAG_WAIT) \ | |
713ddf8d | 113 | lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \ |
30efab51 DJ |
114 | } \ |
115 | while (0) | |
116 | #define THREAD_GSCOPE_SET_FLAG() \ | |
117 | do \ | |
118 | { \ | |
119 | THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \ | |
120 | atomic_write_barrier (); \ | |
121 | } \ | |
122 | while (0) | |
30efab51 | 123 | |
02a9f771 DJ |
124 | #endif /* __ASSEMBLER__ */ |
125 | ||
126 | #endif /* tls.h */ |