(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[glibc.git] / linuxthreads / sysdeps / ia64 / tls.h
blob3ec2eda783702cdcfeb3d35479a6771d1b72a7e8
1 /* Definitions for thread-local data handling. linuxthreads/IA-64 version.
2 Copyright (C) 2002, 2003, 2004 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
18 02111-1307 USA. */
20 #ifndef _TLS_H
21 #define _TLS_H
23 #ifndef __ASSEMBLER__
25 # include <dl-sysdep.h>
26 # include <pt-machine.h>
27 # include <stddef.h>
29 /* Type for the dtv. */
30 typedef union dtv
32 size_t counter;
33 void *pointer;
34 } dtv_t;
36 #else /* __ASSEMBLER__ */
37 # include <tcb-offsets.h>
38 #endif /* __ASSEMBLER__ */
40 #ifdef HAVE_TLS_SUPPORT
42 /* Signal that TLS support is available. */
43 # define USE_TLS 1
45 # ifndef __ASSEMBLER__
47 typedef struct
49 dtv_t *dtv;
50 void *private;
51 } tcbhead_t;
53 /* This is the size of the initial TCB. */
54 # define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
56 /* Alignment requirements for the initial TCB. */
57 # define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
59 /* This is the size of the TCB. */
60 # define TLS_TCB_SIZE sizeof (tcbhead_t)
62 /* This is the size we need before TCB. */
63 # define TLS_PRE_TCB_SIZE sizeof (struct _pthread_descr_struct)
65 /* Alignment requirements for the TCB. */
66 # define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct)
68 /* The DTV is allocated at the TP; the TCB is placed elsewhere. */
69 # define TLS_DTV_AT_TP 1
71 /* Install the dtv pointer. The pointer passed is to the element with
72 index -1 which contain the length. */
73 # define INSTALL_DTV(tcbp, dtvp) \
74 ((tcbhead_t *) (tcbp))->dtv = (dtvp) + 1
76 /* Install new dtv for current thread. */
77 # define INSTALL_NEW_DTV(DTV) \
78 (((tcbhead_t *)__thread_self)->dtv = (DTV))
80 /* Return dtv of given thread descriptor. */
81 # define GET_DTV(tcbp) \
82 (((tcbhead_t *) (tcbp))->dtv)
84 #if defined NEED_DL_SYSINFO
85 # define INIT_SYSINFO \
86 (((tcbhead_t *) __thread_self)->private = (void *) GLRO(dl_sysinfo))
87 #else
88 # define INIT_SYSINFO 0
89 #endif
91 /* Code to initially initialize the thread pointer. This might need
92 special attention since 'errno' is not yet available and if the
93 operation can cause a failure 'errno' must not be touched. */
94 # define TLS_INIT_TP(tcbp, secondcall) \
95 (__thread_self = (__typeof (__thread_self)) (tcbp), INIT_SYSINFO, NULL)
97 /* Return the address of the dtv for the current thread. */
98 # define THREAD_DTV() \
99 (((tcbhead_t *)__thread_self)->dtv)
101 /* Return the thread descriptor for the current thread. */
102 # undef THREAD_SELF
103 # define THREAD_SELF (__thread_self - 1)
105 # undef INIT_THREAD_SELF
106 # define INIT_THREAD_SELF(descr, nr) \
107 (__thread_self = (struct _pthread_descr_struct *)(descr) + 1)
109 # define TLS_MULTIPLE_THREADS_IN_TCB 1
111 /* Get the thread descriptor definition. */
112 # include <linuxthreads/descr.h>
114 # endif
116 #else
118 # ifndef __ASSEMBLER__
120 typedef struct
122 void *tcb;
123 dtv_t *dtv;
124 void *self;
125 int multiple_threads;
126 } tcbhead_t;
128 /* Get the thread descriptor definition. */
129 # include <linuxthreads/descr.h>
131 # define NONTLS_INIT_TP \
132 do { \
133 static const tcbhead_t nontls_init_tp = { .multiple_threads = 0 }; \
134 __thread_self = (__typeof (__thread_self)) &nontls_init_tp; \
135 } while (0)
137 #endif
139 #endif /* USE_TLS */
141 #endif /* tls.h */