(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[glibc.git] / nptl / sysdeps / ia64 / tls.h
blob4591a415c0569ea5b821196fa9f219447a36c3a5
1 /* Definition for thread-local data handling. nptl/IA-64 version.
2 Copyright (C) 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 1
23 #include <dl-sysdep.h>
24 #ifndef __ASSEMBLER__
25 # include <stddef.h>
26 # include <stdint.h>
27 # include <stdlib.h>
28 # include <list.h>
31 /* Type for the dtv. */
32 typedef union dtv
34 size_t counter;
35 void *pointer;
36 } dtv_t;
39 typedef struct
41 dtv_t *dtv;
42 void *private;
43 } tcbhead_t;
45 register struct pthread *__thread_self __asm__("r13");
47 # define TLS_MULTIPLE_THREADS_IN_TCB 1
49 #else /* __ASSEMBLER__ */
50 # include <tcb-offsets.h>
51 #endif
54 /* We require TLS support in the tools. */
55 #ifndef HAVE_TLS_SUPPORT
56 # error "TLS support is required."
57 #endif
59 /* Signal that TLS support is available. */
60 #define USE_TLS 1
62 /* Alignment requirement for the stack. */
63 #define STACK_ALIGN 16
65 #ifndef __ASSEMBLER__
66 /* Get system call information. */
67 # include <sysdep.h>
69 /* This is the size of the initial TCB. */
70 # define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
72 /* Alignment requirements for the initial TCB. */
73 # define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
75 /* This is the size of the TCB. */
76 # define TLS_TCB_SIZE sizeof (tcbhead_t)
78 /* This is the size we need before TCB. */
79 # define TLS_PRE_TCB_SIZE sizeof (struct pthread)
81 /* Alignment requirements for the TCB. */
82 # define TLS_TCB_ALIGN __alignof__ (struct pthread)
84 /* The DTV is allocated at the TP; the TCB is placed elsewhere. */
85 # define TLS_DTV_AT_TP 1
87 /* Get the thread descriptor definition. */
88 # include <nptl/descr.h>
90 /* Install the dtv pointer. The pointer passed is to the element with
91 index -1 which contain the length. */
92 # define INSTALL_DTV(descr, dtvp) \
93 ((tcbhead_t *) (descr))->dtv = (dtvp) + 1
95 /* Install new dtv for current thread. */
96 # define INSTALL_NEW_DTV(DTV) \
97 (((tcbhead_t *)__thread_self)->dtv = (DTV))
99 /* Return dtv of given thread descriptor. */
100 # define GET_DTV(descr) \
101 (((tcbhead_t *) (descr))->dtv)
103 #define THREAD_SELF_SYSINFO (((tcbhead_t *) __thread_self)->private)
104 #define THREAD_SYSINFO(pd) (((tcbhead_t *) ((pd) + 1))->private)
106 #if defined NEED_DL_SYSINFO
107 # define INIT_SYSINFO THREAD_SELF_SYSINFO = (void *) GLRO(dl_sysinfo)
108 #else
109 # define INIT_SYSINFO NULL
110 #endif
112 /* Code to initially initialize the thread pointer. This might need
113 special attention since 'errno' is not yet available and if the
114 operation can cause a failure 'errno' must not be touched. */
115 # define TLS_INIT_TP(thrdescr, secondcall) \
116 (__thread_self = (thrdescr), INIT_SYSINFO, NULL)
118 /* Return the address of the dtv for the current thread. */
119 # define THREAD_DTV() \
120 (((tcbhead_t *)__thread_self)->dtv)
122 /* Return the thread descriptor for the current thread. */
123 # define THREAD_SELF (__thread_self - 1)
125 /* Magic for libthread_db to know how to do THREAD_SELF. */
126 # define DB_THREAD_SELF REGISTER (64, 64, 13 * 8, -sizeof (struct pthread))
128 /* Access to data in the thread descriptor is easy. */
129 #define THREAD_GETMEM(descr, member) \
130 descr->member
131 #define THREAD_GETMEM_NC(descr, member, idx) \
132 descr->member[idx]
133 #define THREAD_SETMEM(descr, member, value) \
134 descr->member = (value)
135 #define THREAD_SETMEM_NC(descr, member, idx, value) \
136 descr->member[idx] = (value)
138 #endif /* __ASSEMBLER__ */
140 #endif /* tls.h */