DMTCP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Classes | Macros | Typedefs
tls-x86_64.h File Reference
#include <asm/prctl.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <sysdep.h>
#include <nptl/descr.h>

Go to the source code of this file.

Classes

union  dtv
 
struct  tcbhead_t
 

Macros

#define USE_TLS   1
 
#define STACK_ALIGN   16
 
#define LOCK_PREFIX   "lock;"
 
#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 TLS_GET_FS()   ({ int __seg; __asm ("movl %%fs, %0" : "=q" (__seg)); __seg; })
 
#define TLS_SET_FS(val)   __asm ("movl %0, %%fs" :: "q" (val))
 
#define TLS_INIT_TP(thrdescr, secondcall)
 
#define THREAD_DTV()
 
#define THREAD_SELF
 
#define DB_THREAD_SELF_INCLUDE   <sys/reg.h> /* For the FS constant. */
 
#define DB_THREAD_SELF   CONST_THREAD_AREA (64, FS)
 
#define THREAD_GETMEM(descr, member)
 
#define THREAD_GETMEM_NC(descr, member, idx)
 
#define IMM_MODE   "ir"
 
#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)
 

Typedefs

typedef union dtv dtv_t
 

Macro Definition Documentation

#define CALL_THREAD_FCT (   descr)
Value:
({ void *__res; \
asm volatile ("movq %%fs:%P2, %%rdi\n\t" \
"callq *%%fs:%P1" \
: "=a" (__res) \
: "i" (offsetof (struct pthread, start_routine)), \
"i" (offsetof (struct pthread, arg)) \
: "di", "si", "cx", "dx", "r8", "r9", "r10", "r11", \
"memory", "cc"); \
__res; })

Definition at line 314 of file tls-x86_64.h.

#define DB_THREAD_SELF   CONST_THREAD_AREA (64, FS)

Definition at line 176 of file tls-x86_64.h.

#define DB_THREAD_SELF_INCLUDE   <sys/reg.h> /* For the FS constant. */

Definition at line 175 of file tls-x86_64.h.

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

Definition at line 118 of file tls-x86_64.h.

#define IMM_MODE   "ir"

Definition at line 235 of file tls-x86_64.h.

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

Definition at line 109 of file tls-x86_64.h.

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

Definition at line 113 of file tls-x86_64.h.

#define LOCK_PREFIX   "lock;"

Definition at line 84 of file tls-x86_64.h.

#define STACK_ALIGN   16

Definition at line 69 of file tls-x86_64.h.

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

Definition at line 304 of file tls-x86_64.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, %%fs:%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 289 of file tls-x86_64.h.

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

Definition at line 337 of file tls-x86_64.h.

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

Definition at line 329 of file tls-x86_64.h.

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

Definition at line 157 of file tls-x86_64.h.

#define THREAD_GETMEM (   descr,
  member 
)
Value:
({ __typeof (descr->member) __value; \
if (sizeof (__value) == 1) \
asm volatile ("movb %%fs:%P2,%b0" \
: "=q" (__value) \
: "0" (0), "i" (offsetof (struct pthread, member))); \
else if (sizeof (__value) == 4) \
asm volatile ("movl %%fs:%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 ("movq %%fs:%P1,%q0" \
: "=r" (__value) \
: "i" (offsetof (struct pthread, member))); \
} \
__value; })

Definition at line 179 of file tls-x86_64.h.

#define THREAD_GETMEM_NC (   descr,
  member,
  idx 
)
Value:
({ __typeof (descr->member[0]) __value; \
if (sizeof (__value) == 1) \
asm volatile ("movb %%fs:%P2(%q3),%b0" \
: "=q" (__value) \
: "0" (0), "i" (offsetof (struct pthread, member[0])), \
"r" (idx)); \
else if (sizeof (__value) == 4) \
asm volatile ("movl %%fs:%P1(,%q2,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 ("movq %%fs:%P1(,%q2,8),%q0" \
: "=r" (__value) \
: "i" (offsetof (struct pthread, member[0])), \
"r" (idx)); \
} \
__value; })

Definition at line 204 of file tls-x86_64.h.

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

Definition at line 168 of file tls-x86_64.h.

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

Definition at line 335 of file tls-x86_64.h.

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

Definition at line 327 of file tls-x86_64.h.

#define THREAD_SETMEM (   descr,
  member,
  value 
)
Value:
({ if (sizeof (descr->member) == 1) \
asm volatile ("movb %b0,%%fs:%P1" : \
: "iq" (value), \
"i" (offsetof (struct pthread, member))); \
else if (sizeof (descr->member) == 4) \
asm volatile ("movl %0,%%fs:%P1" : \
: IMM_MODE (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 ("movq %q0,%%fs:%P1" : \
: IMM_MODE ((unsigned long int) value), \
"i" (offsetof (struct pthread, member))); \
}})

Definition at line 240 of file tls-x86_64.h.

#define THREAD_SETMEM_NC (   descr,
  member,
  idx,
  value 
)
Value:
({ if (sizeof (descr->member[0]) == 1) \
asm volatile ("movb %b0,%%fs:%P1(%q2)" : \
: "iq" (value), \
"i" (offsetof (struct pthread, member[0])), \
"r" (idx)); \
else if (sizeof (descr->member[0]) == 4) \
asm volatile ("movl %0,%%fs:%P1(,%q2,4)" : \
: IMM_MODE (value), \
"i" (offsetof (struct pthread, member[0])), \
"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 ("movq %q0,%%fs:%P1(,%q2,8)" : \
: IMM_MODE ((unsigned long int) value), \
"i" (offsetof (struct pthread, member[0])), \
"r" (idx)); \
}})

Definition at line 263 of file tls-x86_64.h.

#define TLS_GET_FS ( )    ({ int __seg; __asm ("movl %%fs, %0" : "=q" (__seg)); __seg; })

Definition at line 123 of file tls-x86_64.h.

#define TLS_INIT_TCB_ALIGN   __alignof__ (struct pthread)

Definition at line 94 of file tls-x86_64.h.

#define TLS_INIT_TCB_SIZE   sizeof (struct pthread)

Definition at line 91 of file tls-x86_64.h.

#define TLS_INIT_TP (   thrdescr,
  secondcall 
)
Value:
({ void *_thrdescr = (thrdescr); \
tcbhead_t *_head = _thrdescr; \
int _result; \
\
_head->tcb = _thrdescr; \
/* For now the thread descriptor is at the same address. */ \
_head->self = _thrdescr; \
\
/* It is a simple syscall to set the %fs value for the thread. */ \
asm volatile ("syscall" \
: "=a" (_result) \
: "0" ((unsigned long int) __NR_arch_prctl), \
"D" ((unsigned long int) ARCH_SET_FS), \
"S" (_thrdescr) \
: "memory", "cc", "r11", "cx"); \
\
_result ? "cannot set %fs base address for thread-local storage" : 0; \
})

Definition at line 135 of file tls-x86_64.h.

#define TLS_SET_FS (   val)    __asm ("movl %0, %%fs" :: "q" (val))

Definition at line 125 of file tls-x86_64.h.

#define TLS_TCB_ALIGN   __alignof__ (struct pthread)

Definition at line 100 of file tls-x86_64.h.

#define TLS_TCB_AT_TP   1

Definition at line 104 of file tls-x86_64.h.

#define TLS_TCB_SIZE   sizeof (struct pthread)

Definition at line 97 of file tls-x86_64.h.

#define USE_TLS   1

Definition at line 66 of file tls-x86_64.h.

Typedef Documentation

typedef union dtv dtv_t