1 /* Definition for thread-local data handling. NPTL/s390 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
23 #include <dl-sysdep.h>
31 /* Type for the dtv. */
41 void *tcb
; /* Pointer to the TCB. Not necessary the
42 thread descriptor used by libpthread. */
44 void *self
; /* Pointer to the thread descriptor. */
46 # ifdef NEED_DL_SYSINFO
52 # define TLS_MULTIPLE_THREADS_IN_TCB 1
55 #else /* __ASSEMBLER__ */
56 # include <tcb-offsets.h>
60 /* We require TLS support in the tools. */
61 #ifndef HAVE_TLS_SUPPORT
62 # error "TLS support is required."
65 /* Signal that TLS support is available. */
68 /* Alignment requirement for the stack. For IA-32 this is governed by
69 the SSE memory functions. */
70 #define STACK_ALIGN 16
73 /* Get system call information. */
76 /* Get the thread descriptor definition. */
77 # include <nptl/descr.h>
79 /* This is the size of the initial TCB. */
80 # define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
82 /* Alignment requirements for the initial TCB. */
83 # define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
85 /* This is the size of the TCB. */
86 # define TLS_TCB_SIZE sizeof (struct pthread)
88 /* Alignment requirements for the TCB. */
89 # define TLS_TCB_ALIGN __alignof__ (struct pthread)
91 /* The TCB can have any size and the memory following the address the
92 thread pointer points to is unspecified. Allocate the TCB there. */
93 # define TLS_TCB_AT_TP 1
96 /* Install the dtv pointer. The pointer passed is to the element with
97 index -1 which contain the length. */
98 # define INSTALL_DTV(descr, dtvp) \
99 ((tcbhead_t *) (descr))->dtv = (dtvp) + 1
101 /* Install new dtv for current thread. */
102 # define INSTALL_NEW_DTV(dtv) \
103 (((tcbhead_t *) __builtin_thread_pointer ())->dtv = (dtv))
105 /* Return dtv of given thread descriptor. */
106 # define GET_DTV(descr) \
107 (((tcbhead_t *) (descr))->dtv)
109 #if defined NEED_DL_SYSINFO && defined SHARED
110 # define INIT_SYSINFO \
111 _head->sysinfo = GLRO(dl_sysinfo)
113 # define INIT_SYSINFO
116 /* Code to initially initialize the thread pointer. This might need
117 special attention since 'errno' is not yet available and if the
118 operation can cause a failure 'errno' must not be touched. */
119 # define TLS_INIT_TP(thrdescr, secondcall) \
120 ({ void *_thrdescr = (thrdescr); \
121 tcbhead_t *_head = _thrdescr; \
123 _head->tcb = _thrdescr; \
124 /* For now the thread descriptor is at the same address. */ \
125 _head->self = _thrdescr; \
126 /* New syscall handling support. */ \
129 __builtin_set_thread_pointer (_thrdescr); \
133 /* Return the address of the dtv for the current thread. */
134 # define THREAD_DTV() \
135 (((tcbhead_t *) __builtin_thread_pointer ())->dtv)
137 /* Return the thread descriptor for the current thread. */
138 # define THREAD_SELF ((struct pthread *) __builtin_thread_pointer ())
140 /* Magic for libthread_db to know how to do THREAD_SELF. */
141 # define DB_THREAD_SELF REGISTER (32, 32, 18 * 4, 0) \
142 REGISTER (64, __WORDSIZE, 18 * 8, 0)
144 /* Access to data in the thread descriptor is easy. */
145 #define THREAD_GETMEM(descr, member) \
147 #define THREAD_GETMEM_NC(descr, member, idx) \
149 #define THREAD_SETMEM(descr, member, value) \
150 descr->member = (value)
151 #define THREAD_SETMEM_NC(descr, member, idx, value) \
152 descr->member[idx] = (value)
154 #endif /* __ASSEMBLER__ */