2.9
[glibc/nacl-glibc.git] / sysdeps / mach / hurd / tls.h
blob8ad3f1a28ba7b75ec9d7f91d23048a7f5581038e
1 /* Definitions for thread-local data handling. Hurd version.
2 Copyright (C) 2003, 2005, 2007 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 #if defined HAVE_TLS_SUPPORT && !defined __ASSEMBLER__
25 # include <stddef.h>
26 # include <stdbool.h>
27 # include <mach/mig_errors.h>
28 # include <mach.h>
31 /* Type for the dtv. */
32 typedef union dtv
34 size_t counter;
35 struct
37 void *val;
38 bool is_static;
39 } pointer;
40 } dtv_t;
43 /* Type of the TCB. */
44 typedef struct
46 void *tcb; /* Points to this structure. */
47 dtv_t *dtv; /* Vector of pointers to TLS data. */
48 thread_t self; /* This thread's control port. */
49 } tcbhead_t;
52 /* This is the size of the initial TCB. */
53 # define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
55 /* Alignment requirements for the initial TCB. */
56 # define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
58 /* This is the size of the TCB. */
59 # define TLS_TCB_SIZE TLS_INIT_TCB_SIZE /* XXX */
61 /* Alignment requirements for the TCB. */
62 # define TLS_TCB_ALIGN TLS_INIT_TCB_ALIGN /* XXX */
65 /* Install the dtv pointer. The pointer passed is to the element with
66 index -1 which contain the length. */
67 # define INSTALL_DTV(descr, dtvp) \
68 ((tcbhead_t *) (descr))->dtv = (dtvp) + 1
70 /* Return dtv of given thread descriptor. */
71 # define GET_DTV(descr) \
72 (((tcbhead_t *) (descr))->dtv)
74 #endif /* HAVE_TLS_SUPPORT */
77 #endif /* tls.h */