(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[glibc.git] / linuxthreads / sysdeps / alpha / tls.h
blob261d333eb4dec31be2e5e331b4002172b7be8d42
1 /* Definitions for thread-local data handling. linuxthreads/Alpha version.
2 Copyright (C) 2002, 2003 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 <pt-machine.h>
26 # include <stddef.h>
28 /* Type for the dtv. */
29 typedef union dtv
31 size_t counter;
32 void *pointer;
33 } dtv_t;
36 typedef struct
38 dtv_t *dtv;
40 /* Reserved for the thread implementation. Unused in LinuxThreads. */
41 void *private;
42 } tcbhead_t;
43 #endif
46 #ifdef HAVE_TLS_SUPPORT
48 /* Signal that TLS support is available. */
49 # define USE_TLS 1
51 # ifndef __ASSEMBLER__
52 /* Get system call information. */
53 # include <sysdep.h>
55 /* This is the size of the initial TCB. */
56 # define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
58 /* Alignment requirements for the initial TCB. */
59 # define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
61 /* This is the size of the TCB. */
62 # define TLS_TCB_SIZE sizeof (tcbhead_t)
64 /* Alignment requirements for the TCB. */
65 # define TLS_TCB_ALIGN __alignof__ (tcbhead_t)
67 /* This is the size we need before TCB. */
68 # define TLS_PRE_TCB_SIZE sizeof (struct _pthread_descr_struct)
70 /* The DTV is allocated at the TP; the TCB is placed elsewhere. */
71 # define TLS_DTV_AT_TP 1
73 /* Install the dtv pointer. The pointer passed is to the element with
74 index -1 which contain the length. */
75 # define INSTALL_DTV(TCBP, DTVP) \
76 (((tcbhead_t *) (TCBP))->dtv = (DTVP) + 1)
78 /* Install new dtv for current thread. */
79 # define INSTALL_NEW_DTV(DTV) \
80 (((tcbhead_t *)__builtin_thread_pointer ())->dtv = (DTV))
82 /* Return dtv of given thread descriptor. */
83 # define GET_DTV(TCBP) \
84 (((tcbhead_t *) (TCBP))->dtv)
86 /* Code to initially initialize the thread pointer. This might need
87 special attention since 'errno' is not yet available and if the
88 operation can cause a failure 'errno' must not be touched. */
89 # define TLS_INIT_TP(TCBP, SECONDCALL) \
90 (__builtin_set_thread_pointer (TCBP), 0)
92 /* Return the address of the dtv for the current thread. */
93 # define THREAD_DTV() \
94 (((tcbhead_t *)__builtin_thread_pointer ())->dtv)
96 /* Return the thread descriptor for the current thread. */
97 # undef THREAD_SELF
98 # define THREAD_SELF \
99 ((pthread_descr)__builtin_thread_pointer () - 1)
101 # undef INIT_THREAD_SELF
102 # define INIT_THREAD_SELF(DESCR, NR) \
103 __builtin_set_thread_pointer ((struct _pthread_descr_struct *)(DESCR) + 1)
105 /* Get the thread descriptor definition. */
106 # include <linuxthreads/descr.h>
108 /* ??? Generic bits of LinuxThreads may call these macros with
109 DESCR set to NULL. We are expected to be able to reference
110 the "current" value.
112 In our case, we'd really prefer to use DESCR, since lots of
113 PAL_code calls would be expensive. We can only trust that
114 the compiler does its job and unifies the multiple
115 __builtin_thread_pointer instances. */
117 #define THREAD_GETMEM(descr, member) \
118 ((void) sizeof (descr), THREAD_SELF->member)
119 #define THREAD_GETMEM_NC(descr, member) \
120 ((void) sizeof (descr), THREAD_SELF->member)
121 #define THREAD_SETMEM(descr, member, value) \
122 ((void) sizeof (descr), THREAD_SELF->member = (value))
123 #define THREAD_SETMEM_NC(descr, member, value) \
124 ((void) sizeof (descr), THREAD_SELF->member = (value))
126 # endif /* HAVE_TLS_SUPPORT */
127 #endif /* __ASSEMBLER__ */
129 #endif /* tls.h */