Back to index

glibc  2.9
Classes | Defines | Functions
useldt.h File Reference
#include <stddef.h>
#include <stdlib.h>
#include <sysdep.h>

Go to the source code of this file.

Classes

struct  modify_ldt_ldt_s

Defines

#define THREAD_SELF
#define DO_MODIFY_LDT(descr, nr)
#define USETLS_EBX_ARG   "b"
#define USETLS_LOAD_EBX
#define DO_SET_THREAD_AREA_REUSE(nr)   (!__builtin_constant_p (nr) || (nr))
#define DO_SET_THREAD_AREA(descr, nr)
#define INIT_THREAD_SELF(descr, nr)   DO_MODIFY_LDT (descr, nr)
#define FREE_THREAD(descr, nr)
#define THREAD_GETMEM(descr, member)
#define THREAD_GETMEM_NC(descr, member)
#define THREAD_SETMEM(descr, member, value)
#define THREAD_SETMEM_NC(descr, member, value)

Functions

int __modify_ldt (int, struct modify_ldt_ldt_s *, size_t)

Class Documentation

struct modify_ldt_ldt_s

Definition at line 32 of file useldt.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

Define Documentation

#define DO_MODIFY_LDT (   descr,
  nr 
)
Value:
({                                                                   \
  struct modify_ldt_ldt_s ldt_entry =                                       \
    { nr, (unsigned long int) (descr), 0xfffff /* 4GB in pages */,          \
      1, 0, 0, 1, 0, 1, 0 };                                                \
  if (__modify_ldt (1, &ldt_entry, sizeof (ldt_entry)) != 0)                \
    abort ();                                                        \
  asm ("movw %w0, %%gs" : : "q" (nr * 8 + 7));                              \
})

Definition at line 68 of file useldt.h.

#define DO_SET_THREAD_AREA (   descr,
  nr 
)

Definition at line 96 of file useldt.h.

#define DO_SET_THREAD_AREA_REUSE (   nr)    (!__builtin_constant_p (nr) || (nr))

Definition at line 94 of file useldt.h.

#define FREE_THREAD (   descr,
  nr 
)
Value:
{                                                                    \
  struct modify_ldt_ldt_s ldt_entry =                                       \
    { nr, 0, 0, 0, 0, 1, 0, 1, 0, 0 };                                      \
  __modify_ldt (1, &ldt_entry, sizeof (ldt_entry));                         \
}

Definition at line 179 of file useldt.h.

#define INIT_THREAD_SELF (   descr,
  nr 
)    DO_MODIFY_LDT (descr, nr)

Definition at line 160 of file useldt.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_descr_struct,      \
                                      member)));                     \
  else if (sizeof (__value) == 4)                                    \
    __asm__ __volatile__ ("movl %%gs:%P1,%0"                                \
                       : "=r" (__value)                              \
                       : "i" (offsetof (struct _pthread_descr_struct,      \
                                      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_descr_struct,    \
                                        member)),                           \
                           "i" (offsetof (struct _pthread_descr_struct,    \
                                        member) + 4));               \
    }                                                                \
  __value;                                                           \
})

Definition at line 188 of file useldt.h.

#define THREAD_GETMEM_NC (   descr,
  member 
)
Value:
({                                                                   \
  __typeof__ (descr->member) __value;                                       \
  if (sizeof (__value) == 1)                                                \
    __asm__ __volatile__ ("movb %%gs:(%2),%b0"                              \
                       : "=q" (__value)                              \
                       : "0" (0),                                    \
                         "r" (offsetof (struct _pthread_descr_struct,      \
                                      member)));                     \
  else if (sizeof (__value) == 4)                                    \
    __asm__ __volatile__ ("movl %%gs:(%1),%0"                               \
                       : "=r" (__value)                              \
                       : "r" (offsetof (struct _pthread_descr_struct,      \
                                      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:(%1),%%eax\n\t"                      \
                         "movl %%gs:4(%1),%%edx"                     \
                         : "=&A" (__value)                                  \
                         : "r" (offsetof (struct _pthread_descr_struct,    \
                                        member)));                          \
    }                                                                \
  __value;                                                           \
})

Definition at line 220 of file useldt.h.

#define THREAD_SELF
Value:
({                                                                   \
  register pthread_descr __self;                                     \
  __asm__ ("movl %%gs:%c1,%0" : "=r" (__self)                               \
          : "i" (offsetof (struct _pthread_descr_struct,                    \
                         p_header.data.self)));                      \
  __self;                                                            \
})

Definition at line 56 of file useldt.h.

#define THREAD_SETMEM (   descr,
  member,
  value 
)
Value:
({                                                                   \
  __typeof__ (descr->member) __value = (value);                             \
  if (sizeof (__value) == 1)                                                \
    __asm__ __volatile__ ("movb %0,%%gs:%P1" :                              \
                       : "q" (__value),                              \
                         "i" (offsetof (struct _pthread_descr_struct,      \
                                      member)));                     \
  else if (sizeof (__value) == 4)                                    \
    __asm__ __volatile__ ("movl %0,%%gs:%P1" :                              \
                       : "r" (__value),                              \
                         "i" (offsetof (struct _pthread_descr_struct,      \
                                      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 %%eax,%%gs:%P1\n\n"                       \
                         "movl %%edx,%%gs:%P2" :                     \
                         : "A" (__value),                            \
                           "i" (offsetof (struct _pthread_descr_struct,    \
                                        member)),                           \
                           "i" (offsetof (struct _pthread_descr_struct,    \
                                        member) + 4));               \
    }                                                                \
})

Definition at line 250 of file useldt.h.

#define THREAD_SETMEM_NC (   descr,
  member,
  value 
)
Value:
({                                                                   \
  __typeof__ (descr->member) __value = (value);                             \
  if (sizeof (__value) == 1)                                                \
    __asm__ __volatile__ ("movb %0,%%gs:(%1)" :                             \
                       : "q" (__value),                              \
                         "r" (offsetof (struct _pthread_descr_struct,      \
                                      member)));                     \
  else if (sizeof (__value) == 4)                                    \
    __asm__ __volatile__ ("movl %0,%%gs:(%1)" :                             \
                       : "r" (__value),                              \
                         "r" (offsetof (struct _pthread_descr_struct,      \
                                      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 %%eax,%%gs:(%1)\n\t"                      \
                         "movl %%edx,%%gs:4(%1)" :                          \
                         : "A" (__value),                            \
                           "r" (offsetof (struct _pthread_descr_struct,    \
                                        member)));                          \
    }                                                                \
})

Definition at line 280 of file useldt.h.

#define USETLS_EBX_ARG   "b"

Definition at line 82 of file useldt.h.

#define USETLS_LOAD_EBX

Definition at line 83 of file useldt.h.


Function Documentation

int __modify_ldt ( int  ,
struct modify_ldt_ldt_s ,
size_t   
)