* sysdeps/powerpc/powerpc32/fpu/s_ceil.S (TWO52.0): Delete.
[glibc.git] / nptl / sysdeps / s390 / tls.h
blob060dde39df123b433c340600143e668a95a705b1
1 /* Definition for thread-local data handling. NPTL/s390 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 void *tcb; /* Pointer to the TCB. Not necessary the
47 thread descriptor used by libpthread. */
48 dtv_t *dtv;
49 void *self; /* Pointer to the thread descriptor. */
50 int multiple_threads;
51 # ifdef NEED_DL_SYSINFO
52 uintptr_t sysinfo;
53 # endif
54 } tcbhead_t;
56 # ifndef __s390x__
57 # define TLS_MULTIPLE_THREADS_IN_TCB 1
58 # endif
60 #else /* __ASSEMBLER__ */
61 # include <tcb-offsets.h>
62 #endif
65 /* We require TLS support in the tools. */
66 #ifndef HAVE_TLS_SUPPORT
67 # error "TLS support is required."
68 #endif
70 /* Signal that TLS support is available. */
71 #define USE_TLS 1
73 /* Alignment requirement for the stack. For IA-32 this is governed by
74 the SSE memory functions. */
75 #define STACK_ALIGN 16
77 #ifndef __ASSEMBLER__
78 /* Get system call information. */
79 # include <sysdep.h>
81 /* Get the thread descriptor definition. */
82 # include <nptl/descr.h>
84 /* This is the size of the initial TCB. Can't be just sizeof (tcbhead_t),
85 because NPTL getpid, __libc_alloca_cutoff etc. need (almost) the whole
86 struct pthread even when not linked with -lpthread. */
87 # define TLS_INIT_TCB_SIZE sizeof (struct pthread)
89 /* Alignment requirements for the initial TCB. */
90 # define TLS_INIT_TCB_ALIGN __alignof__ (struct pthread)
92 /* This is the size of the TCB. */
93 # define TLS_TCB_SIZE sizeof (struct pthread)
95 /* Alignment requirements for the TCB. */
96 # define TLS_TCB_ALIGN __alignof__ (struct pthread)
98 /* The TCB can have any size and the memory following the address the
99 thread pointer points to is unspecified. Allocate the TCB there. */
100 # define TLS_TCB_AT_TP 1
103 /* Install the dtv pointer. The pointer passed is to the element with
104 index -1 which contain the length. */
105 # define INSTALL_DTV(descr, dtvp) \
106 ((tcbhead_t *) (descr))->dtv = (dtvp) + 1
108 /* Install new dtv for current thread. */
109 # define INSTALL_NEW_DTV(dtv) \
110 (((tcbhead_t *) __builtin_thread_pointer ())->dtv = (dtv))
112 /* Return dtv of given thread descriptor. */
113 # define GET_DTV(descr) \
114 (((tcbhead_t *) (descr))->dtv)
116 #if defined NEED_DL_SYSINFO && defined SHARED
117 # define INIT_SYSINFO \
118 _head->sysinfo = GLRO(dl_sysinfo)
119 #else
120 # define INIT_SYSINFO
121 #endif
123 /* Code to initially initialize the thread pointer. This might need
124 special attention since 'errno' is not yet available and if the
125 operation can cause a failure 'errno' must not be touched. */
126 # define TLS_INIT_TP(thrdescr, secondcall) \
127 ({ void *_thrdescr = (thrdescr); \
128 tcbhead_t *_head = _thrdescr; \
130 _head->tcb = _thrdescr; \
131 /* For now the thread descriptor is at the same address. */ \
132 _head->self = _thrdescr; \
133 /* New syscall handling support. */ \
134 INIT_SYSINFO; \
136 __builtin_set_thread_pointer (_thrdescr); \
137 NULL; \
140 /* Return the address of the dtv for the current thread. */
141 # define THREAD_DTV() \
142 (((tcbhead_t *) __builtin_thread_pointer ())->dtv)
144 /* Return the thread descriptor for the current thread. */
145 # define THREAD_SELF ((struct pthread *) __builtin_thread_pointer ())
147 /* Magic for libthread_db to know how to do THREAD_SELF. */
148 # define DB_THREAD_SELF REGISTER (32, 32, 18 * 4, 0) \
149 REGISTER (64, __WORDSIZE, 18 * 8, 0)
151 /* Access to data in the thread descriptor is easy. */
152 #define THREAD_GETMEM(descr, member) \
153 descr->member
154 #define THREAD_GETMEM_NC(descr, member, idx) \
155 descr->member[idx]
156 #define THREAD_SETMEM(descr, member, value) \
157 descr->member = (value)
158 #define THREAD_SETMEM_NC(descr, member, idx, value) \
159 descr->member[idx] = (value)
161 #endif /* __ASSEMBLER__ */
163 #endif /* tls.h */