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