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, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25 # include <pt-machine.h>
29 /* Type for the dtv. */
40 #else /* __ASSEMBLER__ */
41 # include <tcb-offsets.h>
42 #endif /* __ASSEMBLER__ */
44 #ifdef HAVE_TLS_SUPPORT
46 /* Signal that TLS support is available. */
49 # ifndef __ASSEMBLER__
57 /* This is the size of the initial TCB. */
58 # define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
60 /* Alignment requirements for the initial TCB. */
61 # define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
63 /* This is the size of the TCB. */
64 # define TLS_TCB_SIZE sizeof (tcbhead_t)
66 /* This is the size we need before TCB. */
67 # define TLS_PRE_TCB_SIZE sizeof (struct _pthread_descr_struct)
69 /* Alignment requirements for the TCB. */
70 # define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct)
72 /* The DTV is allocated at the TP; the TCB is placed elsewhere. */
73 # define TLS_DTV_AT_TP 1
75 /* Install the dtv pointer. The pointer passed is to the element with
76 index -1 which contain the length. */
77 # define INSTALL_DTV(tcbp, dtvp) \
78 ((tcbhead_t *) (tcbp))->dtv = (dtvp) + 1
80 /* Install new dtv for current thread. */
81 # define INSTALL_NEW_DTV(DTV) \
82 (((tcbhead_t *)__thread_self)->dtv = (DTV))
84 /* Return dtv of given thread descriptor. */
85 # define GET_DTV(tcbp) \
86 (((tcbhead_t *) (tcbp))->dtv)
88 #if defined NEED_DL_SYSINFO
89 # define INIT_SYSINFO \
90 (((tcbhead_t *) __thread_self)->private = (void *) GLRO(dl_sysinfo))
92 # define INIT_SYSINFO 0
95 /* Code to initially initialize the thread pointer. This might need
96 special attention since 'errno' is not yet available and if the
97 operation can cause a failure 'errno' must not be touched. */
98 # define TLS_INIT_TP(tcbp, secondcall) \
99 (__thread_self = (__typeof (__thread_self)) (tcbp), INIT_SYSINFO, NULL)
101 /* Return the address of the dtv for the current thread. */
102 # define THREAD_DTV() \
103 (((tcbhead_t *)__thread_self)->dtv)
105 /* Return the thread descriptor for the current thread. */
107 # define THREAD_SELF (__thread_self - 1)
109 # undef INIT_THREAD_SELF
110 # define INIT_THREAD_SELF(descr, nr) \
111 (__thread_self = (struct _pthread_descr_struct *)(descr) + 1)
113 # define TLS_MULTIPLE_THREADS_IN_TCB 1
119 # ifndef __ASSEMBLER__
126 int multiple_threads;
129 # define NONTLS_INIT_TP \
131 static const tcbhead_t nontls_init_tp = { .multiple_threads = 0 }; \
132 __thread_self = (__typeof (__thread_self)) &nontls_init_tp; \