Back to index

glibc  2.9
Classes | Defines | Typedefs
tls.h File Reference
#include <dl-sysdep.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <list.h>
#include <sysdep.h>
#include <kernel-features.h>
#include <nptl/descr.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

union  dtv
struct  tcbhead_t
struct  user_desc
union  user_desc_init
struct  dtv.pointer

Defines

#define TLS_MULTIPLE_THREADS_IN_TCB   1
#define STACK_ALIGN   16
#define TLS_INIT_TCB_SIZE   sizeof (struct pthread)
#define TLS_INIT_TCB_ALIGN   __alignof__ (struct pthread)
#define TLS_TCB_SIZE   sizeof (struct pthread)
#define TLS_TCB_ALIGN   __alignof__ (struct pthread)
#define TLS_TCB_AT_TP   1
#define INSTALL_DTV(descr, dtvp)   ((tcbhead_t *) (descr))->dtv = (dtvp) + 1
#define INSTALL_NEW_DTV(dtvp)
#define GET_DTV(descr)   (((tcbhead_t *) (descr))->dtv)
#define THREAD_SELF_SYSINFO   THREAD_GETMEM (THREAD_SELF, header.sysinfo)
#define THREAD_SYSINFO(pd)   ((pd)->header.sysinfo)
#define TLS_GET_GS()   ({ int __seg; __asm ("movw %%gs, %w0" : "=q" (__seg)); __seg & 0xffff; })
#define TLS_SET_GS(val)   __asm ("movw %w0, %%gs" :: "q" (val))
#define __NR_set_thread_area   243
#define TLS_FLAG_WRITABLE   0x00000001
#define TLS_EBX_ARG   "b"
#define TLS_LOAD_EBX
#define INIT_SYSINFO
#define LOCK_PREFIX   "lock;"
#define TLS_INIT_TP(thrdescr, secondcall)
#define THREAD_DTV()
#define THREAD_SELF
#define DB_THREAD_SELF
#define THREAD_GETMEM(descr, member)
#define THREAD_GETMEM_NC(descr, member, idx)
#define THREAD_SETMEM(descr, member, value)
#define THREAD_SETMEM_NC(descr, member, idx, value)
#define THREAD_ATOMIC_CMPXCHG_VAL(descr, member, newval, oldval)
#define THREAD_ATOMIC_BIT_SET(descr, member, bit)
#define CALL_THREAD_FCT(descr)
#define THREAD_SET_STACK_GUARD(value)   THREAD_SETMEM (THREAD_SELF, header.stack_guard, value)
#define THREAD_COPY_STACK_GUARD(descr)
#define THREAD_SET_POINTER_GUARD(value)   THREAD_SETMEM (THREAD_SELF, header.pointer_guard, value)
#define THREAD_COPY_POINTER_GUARD(descr)
#define THREAD_GSCOPE_FLAG_UNUSED   0
#define THREAD_GSCOPE_FLAG_USED   1
#define THREAD_GSCOPE_FLAG_WAIT   2
#define THREAD_GSCOPE_RESET_FLAG()
#define THREAD_GSCOPE_SET_FLAG()   THREAD_SETMEM (THREAD_SELF, header.gscope_flag, THREAD_GSCOPE_FLAG_USED)
#define THREAD_GSCOPE_WAIT()   GL(dl_wait_lookup_done) ()

Typedefs

typedef union dtv dtv_t

Class Documentation

union dtv

Definition at line 30 of file tls.h.

Class Members
size_t counter
struct dtv pointer
struct dtv pointer
struct dtv pointer
struct dtv pointer
struct dtv pointer
struct dtv pointer
struct dtv pointer
struct dtv pointer
struct dtv pointer
struct dtv pointer
struct dtv pointer
struct dtv pointer
struct dtv pointer
struct dtv pointer
struct dtv pointer
struct dtv pointer
struct dtv pointer
struct dtv pointer
struct dtv pointer
struct dtv pointer
struct dtv pointer
struct dtv pointer
struct tcbhead_t

Definition at line 41 of file tls.h.

Collaboration diagram for tcbhead_t:
Class Members
void * __private
dtv_t * dtv
int gscope_flag
int multiple_threads
uintptr_t pointer_guard
void * private
int private_futex
void * self
uintptr_t stack_guard
uintptr_t sysinfo
void * tcb
unsigned long int vgetcpu_cache
struct user_desc

Definition at line 85 of file tls.h.

Class Members
unsigned long int base_addr
unsigned int contents:2
unsigned int empty:25
unsigned int entry_number
unsigned int limit
unsigned int limit_in_pages:1
unsigned int read_exec_only:1
unsigned int seg_32bit:1
unsigned int seg_not_present:1
unsigned int useable:1
union user_desc_init

Definition at line 100 of file tls.h.

Class Members
unsigned int vals
struct dtv.pointer

Definition at line 38 of file tls.h.

Class Members
bool is_static
void * val

Define Documentation

#define __NR_set_thread_area   243

Definition at line 158 of file tls.h.

#define CALL_THREAD_FCT (   descr)
Value:
({ void *__res;                                                      \
     int __ignore1, __ignore2;                                              \
     asm volatile ("pushl %%eax\n\t"                                        \
                 "pushl %%eax\n\t"                                   \
                 "pushl %%eax\n\t"                                   \
                 "pushl %%gs:%P4\n\t"                                       \
                 "call *%%gs:%P3\n\t"                                       \
                 "addl $16, %%esp"                                   \
                 : "=a" (__res), "=c" (__ignore1), "=d" (__ignore2)         \
                 : "i" (offsetof (struct pthread, start_routine)),          \
                   "i" (offsetof (struct pthread, arg)));                   \
     __res; })

Definition at line 392 of file tls.h.

#define DB_THREAD_SELF
Value:
REGISTER_THREAD_AREA (32, offsetof (struct user_regs_struct, xgs), 3) \
  REGISTER_THREAD_AREA (64, 26 * 8, 3) /* x86-64's user_regs_struct->gs */

Definition at line 256 of file tls.h.

#define GET_DTV (   descr)    (((tcbhead_t *) (descr))->dtv)

Definition at line 140 of file tls.h.

#define INIT_SYSINFO

Definition at line 183 of file tls.h.

#define INSTALL_DTV (   descr,
  dtvp 
)    ((tcbhead_t *) (descr))->dtv = (dtvp) + 1

Definition at line 131 of file tls.h.

#define INSTALL_NEW_DTV (   dtvp)
Value:
({ struct pthread *__pd;                                             \
     THREAD_SETMEM (__pd, header.dtv, (dtvp)); })

Definition at line 135 of file tls.h.

#define LOCK_PREFIX   "lock;"

Definition at line 190 of file tls.h.

#define STACK_ALIGN   16

Definition at line 76 of file tls.h.

#define THREAD_ATOMIC_BIT_SET (   descr,
  member,
  bit 
)
Value:
(void) ({ if (sizeof ((descr)->member) == 4)                                \
             asm volatile (LOCK_PREFIX "orl %1, %%gs:%P0"                   \
                         :: "i" (offsetof (struct pthread, member)),        \
                            "ir" (1 << (bit)));                      \
           else                                                      \
             /* Not necessary for other sizes in the moment.  */            \
             abort (); })

Definition at line 381 of file tls.h.

#define THREAD_ATOMIC_CMPXCHG_VAL (   descr,
  member,
  newval,
  oldval 
)
Value:
({ __typeof (descr->member) __ret;                                   \
     __typeof (oldval) __old = (oldval);                             \
     if (sizeof (descr->member) == 4)                                       \
       asm volatile (LOCK_PREFIX "cmpxchgl %2, %%gs:%P3"                    \
                   : "=a" (__ret)                                    \
                   : "0" (__old), "r" (newval),                      \
                     "i" (offsetof (struct pthread, member)));       \
     else                                                            \
       /* Not necessary for other sizes in the moment.  */                  \
       abort ();                                                     \
     __ret; })

Definition at line 366 of file tls.h.

#define THREAD_COPY_POINTER_GUARD (   descr)
Value:
((descr)->header.pointer_guard                                       \
   = THREAD_GETMEM (THREAD_SELF, header.pointer_guard))

Definition at line 418 of file tls.h.

#define THREAD_COPY_STACK_GUARD (   descr)
Value:
((descr)->header.stack_guard                                                \
   = THREAD_GETMEM (THREAD_SELF, header.stack_guard))

Definition at line 410 of file tls.h.

#define THREAD_DTV ( )
Value:
({ struct pthread *__pd;                                             \
     THREAD_GETMEM (__pd, header.dtv); })

Definition at line 238 of file tls.h.

#define THREAD_GETMEM (   descr,
  member 
)
Value:
({ __typeof (descr->member) __value;                                        \
     if (sizeof (__value) == 1)                                             \
       asm volatile ("movb %%gs:%P2,%b0"                             \
                   : "=q" (__value)                                         \
                   : "0" (0), "i" (offsetof (struct pthread, member)));     \
     else if (sizeof (__value) == 4)                                        \
       asm volatile ("movl %%gs:%P1,%0"                                     \
                   : "=r" (__value)                                         \
                   : "i" (offsetof (struct pthread, member)));       \
     else                                                            \
       {                                                             \
        if (sizeof (__value) != 8)                                   \
          /* There should not be any value with a size other than 1,        \
             4 or 8.  */                                             \
          abort ();                                                  \
                                                                     \
        asm volatile ("movl %%gs:%P1,%%eax\n\t"                      \
                     "movl %%gs:%P2,%%edx"                                  \
                     : "=A" (__value)                                       \
                     : "i" (offsetof (struct pthread, member)),             \
                      "i" (offsetof (struct pthread, member) + 4));         \
       }                                                             \
     __value; })

Definition at line 262 of file tls.h.

#define THREAD_GETMEM_NC (   descr,
  member,
  idx 
)
Value:
({ __typeof (descr->member[0]) __value;                              \
     if (sizeof (__value) == 1)                                             \
       asm volatile ("movb %%gs:%P2(%3),%b0"                                \
                   : "=q" (__value)                                         \
                   : "0" (0), "i" (offsetof (struct pthread, member[0])),   \
                   "r" (idx));                                       \
     else if (sizeof (__value) == 4)                                        \
       asm volatile ("movl %%gs:%P1(,%2,4),%0"                              \
                   : "=r" (__value)                                         \
                   : "i" (offsetof (struct pthread, member[0])),            \
                     "r" (idx));                                     \
     else                                                            \
       {                                                             \
        if (sizeof (__value) != 8)                                   \
          /* There should not be any value with a size other than 1,        \
             4 or 8.  */                                             \
          abort ();                                                  \
                                                                     \
        asm volatile  ("movl %%gs:%P1(,%2,8),%%eax\n\t"              \
                     "movl %%gs:4+%P1(,%2,8),%%edx"                         \
                     : "=&A" (__value)                               \
                     : "i" (offsetof (struct pthread, member[0])),          \
                       "r" (idx));                                   \
       }                                                             \
     __value; })

Definition at line 288 of file tls.h.

#define THREAD_GSCOPE_FLAG_UNUSED   0

Definition at line 424 of file tls.h.

#define THREAD_GSCOPE_FLAG_USED   1

Definition at line 425 of file tls.h.

#define THREAD_GSCOPE_FLAG_WAIT   2

Definition at line 426 of file tls.h.

Value:
do                                                                   \
    { int __res;                                                     \
      asm volatile ("xchgl %0, %%gs:%P1"                             \
                  : "=r" (__res)                                     \
                  : "i" (offsetof (struct pthread, header.gscope_flag)),    \
                    "0" (THREAD_GSCOPE_FLAG_UNUSED));                       \
      if (__res == THREAD_GSCOPE_FLAG_WAIT)                                 \
       lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE);    \
    }                                                                \
  while (0)

Definition at line 427 of file tls.h.

#define THREAD_GSCOPE_SET_FLAG ( )    THREAD_SETMEM (THREAD_SELF, header.gscope_flag, THREAD_GSCOPE_FLAG_USED)

Definition at line 438 of file tls.h.

#define THREAD_GSCOPE_WAIT ( )    GL(dl_wait_lookup_done) ()

Definition at line 440 of file tls.h.

#define THREAD_SELF
Value:
({ struct pthread *__self;                                           \
     asm ("movl %%gs:%c1,%0" : "=r" (__self)                                \
         : "i" (offsetof (struct pthread, header.self)));                   \
     __self;})

Definition at line 249 of file tls.h.

Definition at line 143 of file tls.h.

#define THREAD_SET_POINTER_GUARD (   value)    THREAD_SETMEM (THREAD_SELF, header.pointer_guard, value)

Definition at line 416 of file tls.h.

#define THREAD_SET_STACK_GUARD (   value)    THREAD_SETMEM (THREAD_SELF, header.stack_guard, value)

Definition at line 408 of file tls.h.

#define THREAD_SETMEM (   descr,
  member,
  value 
)
Value:
({ if (sizeof (descr->member) == 1)                                         \
       asm volatile ("movb %b0,%%gs:%P1" :                                  \
                   : "iq" (value),                                   \
                     "i" (offsetof (struct pthread, member)));       \
     else if (sizeof (descr->member) == 4)                                  \
       asm volatile ("movl %0,%%gs:%P1" :                            \
                   : "ir" (value),                                   \
                     "i" (offsetof (struct pthread, member)));       \
     else                                                            \
       {                                                             \
        if (sizeof (descr->member) != 8)                             \
          /* There should not be any value with a size other than 1,        \
             4 or 8.  */                                             \
          abort ();                                                  \
                                                                     \
        asm volatile ("movl %%eax,%%gs:%P1\n\t"                      \
                     "movl %%edx,%%gs:%P2" :                                \
                     : "A" (value),                                         \
                      "i" (offsetof (struct pthread, member)),       \
                      "i" (offsetof (struct pthread, member) + 4));         \
       }})

Definition at line 316 of file tls.h.

#define THREAD_SETMEM_NC (   descr,
  member,
  idx,
  value 
)
Value:
({ if (sizeof (descr->member[0]) == 1)                               \
       asm volatile ("movb %b0,%%gs:%P1(%2)" :                              \
                   : "iq" (value),                                   \
                     "i" (offsetof (struct pthread, member)),               \
                     "r" (idx));                                     \
     else if (sizeof (descr->member[0]) == 4)                               \
       asm volatile ("movl %0,%%gs:%P1(,%2,4)" :                     \
                   : "ir" (value),                                   \
                     "i" (offsetof (struct pthread, member)),               \
                     "r" (idx));                                     \
     else                                                            \
       {                                                             \
        if (sizeof (descr->member[0]) != 8)                                 \
          /* There should not be any value with a size other than 1,        \
             4 or 8.  */                                             \
          abort ();                                                  \
                                                                     \
        asm volatile ("movl %%eax,%%gs:%P1(,%2,8)\n\t"                      \
                     "movl %%edx,%%gs:4+%P1(,%2,8)" :                       \
                     : "A" (value),                                         \
                      "i" (offsetof (struct pthread, member)),       \
                      "r" (idx));                                    \
       }})

Definition at line 340 of file tls.h.

#define THREAD_SYSINFO (   pd)    ((pd)->header.sysinfo)

Definition at line 144 of file tls.h.

#define TLS_EBX_ARG   "b"

Definition at line 175 of file tls.h.

#define TLS_FLAG_WRITABLE   0x00000001

Definition at line 161 of file tls.h.

#define TLS_GET_GS ( )    ({ int __seg; __asm ("movw %%gs, %w0" : "=q" (__seg)); __seg & 0xffff; })

Definition at line 148 of file tls.h.

#define TLS_INIT_TCB_ALIGN   __alignof__ (struct pthread)

Definition at line 116 of file tls.h.

#define TLS_INIT_TCB_SIZE   sizeof (struct pthread)

Definition at line 113 of file tls.h.

#define TLS_INIT_TP (   thrdescr,
  secondcall 
)

Definition at line 197 of file tls.h.

#define TLS_LOAD_EBX

Definition at line 176 of file tls.h.

Definition at line 62 of file tls.h.

#define TLS_SET_GS (   val)    __asm ("movw %w0, %%gs" :: "q" (val))

Definition at line 152 of file tls.h.

#define TLS_TCB_ALIGN   __alignof__ (struct pthread)

Definition at line 122 of file tls.h.

#define TLS_TCB_AT_TP   1

Definition at line 126 of file tls.h.

#define TLS_TCB_SIZE   sizeof (struct pthread)

Definition at line 119 of file tls.h.


Typedef Documentation

typedef union dtv dtv_t