Blame SOURCES/sysdep.h

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