|
|
1a097b |
#ifdef _SYSDEP_H
|
|
|
1a097b |
#define _SYSDEP_H 1
|
|
|
1a097b |
|
|
|
1a097b |
#include <stdint.h>
|
|
|
1a097b |
|
|
|
1a097b |
#ifdef __i386__
|
|
|
1a097b |
|
|
|
1a097b |
typedef struct
|
|
|
1a097b |
{
|
|
|
1a097b |
void *tcb;
|
|
|
1a097b |
dtv_t *dtv;
|
|
|
1a097b |
void *self;
|
|
|
1a097b |
int multiple_threads;
|
|
|
1a097b |
uintptr_t sysinfo;
|
|
|
1a097b |
uintptr_t stack_guard;
|
|
|
1a097b |
uintptr_t pointer_guard;
|
|
|
1a097b |
int gscope_flag;
|
|
|
1a097b |
int private_futex;
|
|
|
1a097b |
} tcbhead_t;
|
|
|
1a097b |
|
|
|
1a097b |
# ifdef FOR_GLIBC_2_6_AND_LATER
|
|
|
1a097b |
# define PTR_MANGLE(var) asm ("xorl %%gs:%c2, %0\n" \
|
|
|
1a097b |
"roll $9, %0" \
|
|
|
1a097b |
: "=r" (var) \
|
|
|
1a097b |
: "0" (var), \
|
|
|
1a097b |
"i" (offsetof (tcbhead_t, \
|
|
|
1a097b |
pointer_guard)))
|
|
|
1a097b |
# define PTR_DEMANGLE(var) asm ("rorl $9, %0" \
|
|
|
1a097b |
"xorl %%gs:%c2, %0" \
|
|
|
1a097b |
: "=r" (var) \
|
|
|
1a097b |
: "0" (var), \
|
|
|
1a097b |
"i" (offsetof (tcbhead_t, \
|
|
|
1a097b |
pointer_guard)))
|
|
|
1a097b |
# else
|
|
|
1a097b |
# define PTR_MANGLE(var) asm ("xorl %%gs:%c2, %0" \
|
|
|
1a097b |
: "=r" (var) \
|
|
|
1a097b |
: "0" (var), \
|
|
|
1a097b |
"i" (offsetof (tcbhead_t, \
|
|
|
1a097b |
pointer_guard)))
|
|
|
1a097b |
# define PTR_DEMANGLE(var) asm ("xorl %%gs:%c2, %0" \
|
|
|
1a097b |
: "=r" (var) \
|
|
|
1a097b |
: "0" (var), \
|
|
|
1a097b |
"i" (offsetof (tcbhead_t, \
|
|
|
1a097b |
pointer_guard)))
|
|
|
1a097b |
# endif
|
|
|
1a097b |
|
|
|
1a097b |
#elif defined __x86_64__
|
|
|
1a097b |
|
|
|
1a097b |
typedef struct
|
|
|
1a097b |
{
|
|
|
1a097b |
void *tcb;
|
|
|
1a097b |
void *dtv;
|
|
|
1a097b |
void *self;
|
|
|
1a097b |
int multiple_threads;
|
|
|
1a097b |
int gscope_flag;
|
|
|
1a097b |
uintptr_t sysinfo;
|
|
|
1a097b |
uintptr_t stack_guard;
|
|
|
1a097b |
uintptr_t pointer_guard;
|
|
|
1a097b |
unsigned long int vgetcpu_cache[2];
|
|
|
1a097b |
int private_futex;
|
|
|
1a097b |
int __pad1;
|
|
|
1a097b |
void *__private_tm[5];
|
|
|
1a097b |
} tcbhead_t;
|
|
|
1a097b |
|
|
|
1a097b |
# ifdef FOR_GLIBC_2_6_AND_LATER
|
|
|
1a097b |
# define PTR_MANGLE(var) asm ("xorq %%fs:%c2, %0\n" \
|
|
|
1a097b |
"rolq $17, %0" \
|
|
|
1a097b |
: "=r" (var) \
|
|
|
1a097b |
: "0" (var), \
|
|
|
1a097b |
"i" (offsetof (tcbhead_t, \
|
|
|
1a097b |
pointer_guard)))
|
|
|
1a097b |
# define PTR_DEMANGLE(var) asm ("rorq $17, %0" \
|
|
|
1a097b |
"xorq %%fs:%c2, %0" \
|
|
|
1a097b |
: "=r" (var) \
|
|
|
1a097b |
: "0" (var), \
|
|
|
1a097b |
"i" (offsetof (tcbhead_t, \
|
|
|
1a097b |
pointer_guard)))
|
|
|
1a097b |
# else
|
|
|
1a097b |
# define PTR_MANGLE(var) asm ("xorq %%fs:%c2, %0" \
|
|
|
1a097b |
: "=r" (var) \
|
|
|
1a097b |
: "0" (var), \
|
|
|
1a097b |
"i" (offsetof (tcbhead_t, \
|
|
|
1a097b |
pointer_guard)))
|
|
|
1a097b |
# define PTR_DEMANGLE(var) asm ("xorq %%fs:%c2, %0" \
|
|
|
1a097b |
: "=r" (var) \
|
|
|
1a097b |
: "0" (var), \
|
|
|
1a097b |
"i" (offsetof (tcbhead_t, \
|
|
|
1a097b |
pointer_guard)))
|
|
|
1a097b |
# endif
|
|
|
1a097b |
|
|
|
1a097b |
#elif defined __powerpc__ || defined __powerpc64__
|
|
|
1a097b |
|
|
|
1a097b |
typedef struct
|
|
|
1a097b |
{
|
|
|
1a097b |
uintptr_t pointer_guard;
|
|
|
1a097b |
uintptr_t stack_guard;
|
|
|
1a097b |
void *dtv;
|
|
|
1a097b |
} tcbhead_t;
|
|
|
1a097b |
|
|
|
1a097b |
# ifndef __powerpc64__
|
|
|
1a097b |
register void *__thread_register __asm__ ("r2");
|
|
|
1a097b |
# else
|
|
|
1a097b |
register void *__thread_register __asm__ ("r13");
|
|
|
1a097b |
# endif
|
|
|
1a097b |
|
|
|
1a097b |
# define TLS_TCB_OFFSET 0x7000
|
|
|
1a097b |
|
|
|
1a097b |
# define THREAD_GET_POINTER_GUARD() \
|
|
|
1a097b |
(((tcbhead_t *) ((char *) __thread_register \
|
|
|
1a097b |
- TLS_TCB_OFFSET))[-1].pointer_guard)
|
|
|
1a097b |
|
|
|
1a097b |
# define PTR_MANGLE(var) \
|
|
|
1a097b |
(var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
|
|
|
1a097b |
# define PTR_DEMANGLE(var) PTR_MANGLE (var)
|
|
|
1a097b |
|
|
|
1a097b |
#elif defined __IA_64__
|
|
|
1a097b |
|
|
|
1a097b |
register void *__thread_self __asm__("r13");
|
|
|
1a097b |
|
|
|
1a097b |
#define THREAD_GET_POINTER_GUARD() \
|
|
|
1a097b |
(((uintptr_t *) __thread_self)[-2])
|
|
|
1a097b |
|
|
|
1a097b |
# define PTR_MANGLE(var) \
|
|
|
1a097b |
(var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
|
|
|
1a097b |
# define PTR_DEMANGLE(var) PTR_MANGLE (var)
|
|
|
1a097b |
|
|
|
1a097b |
#elif defined __s390__ || defined __s390x__
|
|
|
1a097b |
|
|
|
1a097b |
typedef struct
|
|
|
1a097b |
{
|
|
|
1a097b |
void *tcb;
|
|
|
1a097b |
void *dtv;
|
|
|
1a097b |
void *self;
|
|
|
1a097b |
int multiple_threads;
|
|
|
1a097b |
uintptr_t sysinfo;
|
|
|
1a097b |
uintptr_t stack_guard;
|
|
|
1a097b |
int gscope_flag;
|
|
|
1a097b |
int private_futex;
|
|
|
1a097b |
} tcbhead_t;
|
|
|
1a097b |
|
|
|
1a097b |
# define THREAD_SELF ((tcbhead_t *) __builtin_thread_pointer ())
|
|
|
1a097b |
|
|
|
1a097b |
#define THREAD_GETMEM(descr, member) \
|
|
|
1a097b |
descr->member
|
|
|
1a097b |
|
|
|
1a097b |
#define THREAD_GET_POINTER_GUARD() \
|
|
|
1a097b |
THREAD_GETMEM (THREAD_SELF, stack_guard)
|
|
|
1a097b |
|
|
|
1a097b |
# define PTR_MANGLE(var) \
|
|
|
1a097b |
(var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
|
|
|
1a097b |
# define PTR_DEMANGLE(var) PTR_MANGLE (var)
|
|
|
1a097b |
|
|
|
1a097b |
#else
|
|
|
1a097b |
|
|
|
1a097b |
# error "missing support for this architecture"
|
|
|
1a097b |
|
|
|
1a097b |
#endif
|
|
|
1a097b |
|
|
|
1a097b |
#endif
|