1 /* Definitions for thread-local data handling. linuxthreads/Alpha version.
2 Copyright (C) 2002 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
25 # include <pt-machine.h>
28 /* Type for the dtv. */
40 /* Reserved for the thread implementation. In the case of LinuxThreads,
41 this is the thread descriptor. */
47 #ifdef HAVE_TLS_SUPPORT
49 /* Signal that TLS support is available. */
52 # ifndef __ASSEMBLER__
53 /* Get system call information. */
56 /* Get the thread descriptor definition. */
57 # include <linuxthreads/descr.h>
59 /* This is the size of the initial TCB. */
60 # define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
62 /* Alignment requirements for the initial TCB. */
63 # define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
65 /* This is the size of the TCB. */
66 # define TLS_TCB_SIZE sizeof (struct _pthread_descr_struct)
68 /* Alignment requirements for the TCB. */
69 # define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct)
71 /* The DTV is allocated at the TP; the TCB is placed elsewhere. */
72 # define TLS_DTV_AT_TP 1
74 /* Install the dtv pointer. The pointer passed is to the element with
75 index -1 which contain the length. */
76 # define INSTALL_DTV(descr, dtvp) \
77 ((tcbhead_t *) (descr))->dtv = (dtvp) + 1
79 /* Install new dtv for current thread. */
80 # define INSTALL_NEW_DTV(DTV) \
81 (((tcbhead_t *)__builtin_thread_pointer ())->dtv = (DTV))
83 /* Return dtv of given thread descriptor. */
84 # define GET_DTV(descr) \
85 (((tcbhead_t *) (descr))->dtv)
87 /* Code to initially initialize the thread pointer. This might need
88 special attention since 'errno' is not yet available and if the
89 operation can cause a failure 'errno' must not be touched. */
90 # define TLS_INIT_TP(descr, secondcall) \
92 register tcbhead_t *__self = (void *)(descr); \
93 __self->tcb = __self; \
94 __builtin_set_thread_pointer(__self); \
98 /* Return the address of the dtv for the current thread. */
99 # define THREAD_DTV() \
100 (((tcbhead_t *)__builtin_thread_pointer ())->dtv)
102 /* Return the thread descriptor for the current thread. */
104 #define THREAD_SELF \
105 ((pthread_descr)(((tcbhead_t *)__builtin_thread_pointer ())->tcb))
107 #undef INIT_THREAD_SELF
109 # endif /* HAVE_TLS_SUPPORT */
110 #endif /* __ASSEMBLER__ */