1 /* Definitions for thread-local data handling. linuxthreads/IA-64 version.
2 Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
24 # include <pt-machine.h>
28 /* Type for the dtv. */
39 #else /* __ASSEMBLER__ */
40 # include <tcb-offsets.h>
41 #endif /* __ASSEMBLER__ */
43 #ifdef HAVE_TLS_SUPPORT
45 /* Signal that TLS support is available. */
48 # ifndef __ASSEMBLER__
56 /* This is the size of the initial TCB. */
57 # define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
59 /* Alignment requirements for the initial TCB. */
60 # define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
62 /* This is the size of the TCB. */
63 # define TLS_TCB_SIZE sizeof (tcbhead_t)
65 /* This is the size we need before TCB. */
66 # define TLS_PRE_TCB_SIZE sizeof (struct _pthread_descr_struct)
68 /* Alignment requirements for the TCB. */
69 # define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct)
71 /* The DTV is allocated at the TP; the TCB is placed elsewhere. */
72 # define TLS_DTV_AT_TP 1
74 /* Install the dtv pointer. The pointer passed is to the element with
75 index -1 which contain the length. */
76 # define INSTALL_DTV(tcbp, dtvp) \
77 ((tcbhead_t *) (tcbp))->dtv = (dtvp) + 1
79 /* Install new dtv for current thread. */
80 # define INSTALL_NEW_DTV(DTV) \
81 (((tcbhead_t *)__thread_self)->dtv = (DTV))
83 /* Return dtv of given thread descriptor. */
84 # define GET_DTV(tcbp) \
85 (((tcbhead_t *) (tcbp))->dtv)
87 #if defined NEED_DL_SYSINFO
88 # define INIT_SYSINFO \
89 (((tcbhead_t *) __thread_self)->private = (void *) GLRO(dl_sysinfo))
91 # define INIT_SYSINFO 0
94 /* Code to initially initialize the thread pointer. This might need
95 special attention since 'errno' is not yet available and if the
96 operation can cause a failure 'errno' must not be touched. */
97 # define TLS_INIT_TP(tcbp, secondcall) \
98 (__thread_self = (__typeof (__thread_self)) (tcbp), INIT_SYSINFO, NULL)
100 /* Return the address of the dtv for the current thread. */
101 # define THREAD_DTV() \
102 (((tcbhead_t *)__thread_self)->dtv)
104 /* Return the thread descriptor for the current thread. */
106 # define THREAD_SELF (__thread_self - 1)
108 # undef INIT_THREAD_SELF
109 # define INIT_THREAD_SELF(descr, nr) \
110 (__thread_self = (struct _pthread_descr_struct *)(descr) + 1)
112 # define TLS_MULTIPLE_THREADS_IN_TCB 1
118 # ifndef __ASSEMBLER__
125 int multiple_threads;
128 # define NONTLS_INIT_TP \
130 static const tcbhead_t nontls_init_tp = { .multiple_threads = 0 }; \
131 __thread_self = (__typeof (__thread_self)) &nontls_init_tp; \