Updated to fedora-glibc-20050208T0948
[glibc.git] / nptl / sysdeps / ia64 / tls.h
bloba435f966cac268d34fad42b8d7654a05ce6d73bd
1 /* Definition for thread-local data handling. nptl/IA-64 version.
2 Copyright (C) 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
18 02111-1307 USA. */
20 #ifndef _TLS_H
21 #define _TLS_H 1
23 #include <dl-sysdep.h>
24 #ifndef __ASSEMBLER__
25 # include <stdbool.h>
26 # include <stddef.h>
27 # include <stdint.h>
28 # include <stdlib.h>
29 # include <list.h>
32 /* Type for the dtv. */
33 typedef union dtv
35 size_t counter;
36 struct
38 void *val;
39 bool is_static;
40 } pointer;
41 } dtv_t;
44 typedef struct
46 dtv_t *dtv;
47 void *private;
48 } tcbhead_t;
50 register struct pthread *__thread_self __asm__("r13");
52 # define TLS_MULTIPLE_THREADS_IN_TCB 1
54 #else /* __ASSEMBLER__ */
55 # include <tcb-offsets.h>
56 #endif
59 /* We require TLS support in the tools. */
60 #ifndef HAVE_TLS_SUPPORT
61 # error "TLS support is required."
62 #endif
64 /* Signal that TLS support is available. */
65 #define USE_TLS 1
67 /* Alignment requirement for the stack. */
68 #define STACK_ALIGN 16
70 #ifndef __ASSEMBLER__
71 /* Get system call information. */
72 # include <sysdep.h>
74 /* This is the size of the initial TCB. */
75 # define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
77 /* Alignment requirements for the initial TCB. */
78 # define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
80 /* This is the size of the TCB. */
81 # define TLS_TCB_SIZE sizeof (tcbhead_t)
83 /* This is the size we need before TCB. */
84 # define TLS_PRE_TCB_SIZE sizeof (struct pthread)
86 /* Alignment requirements for the TCB. */
87 # define TLS_TCB_ALIGN __alignof__ (struct pthread)
89 /* The DTV is allocated at the TP; the TCB is placed elsewhere. */
90 # define TLS_DTV_AT_TP 1
92 /* Get the thread descriptor definition. */
93 # include <nptl/descr.h>
95 /* Install the dtv pointer. The pointer passed is to the element with
96 index -1 which contain the length. */
97 # define INSTALL_DTV(descr, dtvp) \
98 ((tcbhead_t *) (descr))->dtv = (dtvp) + 1
100 /* Install new dtv for current thread. */
101 # define INSTALL_NEW_DTV(DTV) \
102 (((tcbhead_t *)__thread_self)->dtv = (DTV))
104 /* Return dtv of given thread descriptor. */
105 # define GET_DTV(descr) \
106 (((tcbhead_t *) (descr))->dtv)
108 #define THREAD_SELF_SYSINFO (((tcbhead_t *) __thread_self)->private)
109 #define THREAD_SYSINFO(pd) (((tcbhead_t *) ((pd) + 1))->private)
111 #if defined NEED_DL_SYSINFO
112 # define INIT_SYSINFO THREAD_SELF_SYSINFO = (void *) GLRO(dl_sysinfo)
113 #else
114 # define INIT_SYSINFO NULL
115 #endif
117 /* Code to initially initialize the thread pointer. This might need
118 special attention since 'errno' is not yet available and if the
119 operation can cause a failure 'errno' must not be touched. */
120 # define TLS_INIT_TP(thrdescr, secondcall) \
121 (__thread_self = (thrdescr), INIT_SYSINFO, NULL)
123 /* Return the address of the dtv for the current thread. */
124 # define THREAD_DTV() \
125 (((tcbhead_t *)__thread_self)->dtv)
127 /* Return the thread descriptor for the current thread. */
128 # define THREAD_SELF (__thread_self - 1)
130 /* Magic for libthread_db to know how to do THREAD_SELF. */
131 # define DB_THREAD_SELF REGISTER (64, 64, 13 * 8, -sizeof (struct pthread))
133 /* Access to data in the thread descriptor is easy. */
134 #define THREAD_GETMEM(descr, member) \
135 descr->member
136 #define THREAD_GETMEM_NC(descr, member, idx) \
137 descr->member[idx]
138 #define THREAD_SETMEM(descr, member, value) \
139 descr->member = (value)
140 #define THREAD_SETMEM_NC(descr, member, idx, value) \
141 descr->member[idx] = (value)
143 #endif /* __ASSEMBLER__ */
145 #endif /* tls.h */