Back to index

glibc  2.9
tls.h
Go to the documentation of this file.
00001 /* Definitions for thread-local data handling.  Hurd version.
00002    Copyright (C) 2003, 2005, 2007 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #ifndef _TLS_H
00021 #define _TLS_H
00022 
00023 #if defined HAVE_TLS_SUPPORT && !defined __ASSEMBLER__
00024 
00025 # include <stddef.h>
00026 # include <stdbool.h>
00027 # include <mach/mig_errors.h>
00028 # include <mach.h>
00029 
00030 
00031 /* Type for the dtv.  */
00032 typedef union dtv
00033 {
00034   size_t counter;
00035   struct
00036   {
00037     void *val;
00038     bool is_static;
00039   } pointer;
00040 } dtv_t;
00041 
00042 
00043 /* Type of the TCB.  */
00044 typedef struct
00045 {
00046   void *tcb;                /* Points to this structure.  */
00047   dtv_t *dtv;               /* Vector of pointers to TLS data.  */
00048   thread_t self;            /* This thread's control port.  */
00049 } tcbhead_t;
00050 
00051 
00052 /* This is the size of the initial TCB.  */
00053 # define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
00054 
00055 /* Alignment requirements for the initial TCB.  */
00056 # define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
00057 
00058 /* This is the size of the TCB.  */
00059 # define TLS_TCB_SIZE TLS_INIT_TCB_SIZE   /* XXX */
00060 
00061 /* Alignment requirements for the TCB.  */
00062 # define TLS_TCB_ALIGN TLS_INIT_TCB_ALIGN /* XXX */
00063 
00064 
00065 /* Install the dtv pointer.  The pointer passed is to the element with
00066    index -1 which contain the length.  */
00067 # define INSTALL_DTV(descr, dtvp) \
00068   ((tcbhead_t *) (descr))->dtv = (dtvp) + 1
00069 
00070 /* Return dtv of given thread descriptor.  */
00071 # define GET_DTV(descr) \
00072   (((tcbhead_t *) (descr))->dtv)
00073 
00074 #endif /* HAVE_TLS_SUPPORT */
00075 
00076 
00077 #endif /* tls.h */