Back to index

glibc  2.9
Defines | Functions
pt-machine.h File Reference
#include <stddef.h>
#include <stdlib.h>
#include <asm/prctl.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define PT_EI   extern inline __attribute__ ((always_inline))
#define CURRENT_STACK_FRAME   stack_pointer
#define HAS_COMPARE_AND_SWAP
#define THREAD_SELF
#define INIT_THREAD_SELF(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)
#define FLOATING_STACKS   1
#define ARCH_STACK_MAX_SIZE   32*1024*1024
#define BUSY_WAIT_NOP   __asm__ ("rep; nop")

Functions

long int testandset (int *spinlock)
int __compare_and_swap (long int *p, long int oldval, long int newval)
register char *stack_pointer __asm__ ("%rsp") __attribute_used__
int __arch_prctl (int __code, unsigned long __addr)

Define Documentation

#define ARCH_STACK_MAX_SIZE   32*1024*1024

Definition at line 220 of file pt-machine.h.

#define BUSY_WAIT_NOP   __asm__ ("rep; nop")

Definition at line 223 of file pt-machine.h.

#define CURRENT_STACK_FRAME   stack_pointer

Definition at line 39 of file pt-machine.h.

#define FLOATING_STACKS   1

Definition at line 217 of file pt-machine.h.

Definition at line 60 of file pt-machine.h.

#define INIT_THREAD_SELF (   descr,
  nr 
)
Value:
{                                                                    \
  if (__arch_prctl (ARCH_SET_FS, (unsigned long)descr) != 0)                \
    abort ();                                                        \
}

Definition at line 94 of file pt-machine.h.

#define PT_EI   extern inline __attribute__ ((always_inline))

Definition at line 31 of file pt-machine.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_descr_struct,      \
                                      member)));                     \
  else if (sizeof (__value) == 4)                                    \
    __asm__ __volatile__ ("movl %%fs:%P2,%k0"                               \
                       : "=r" (__value)                              \
                       : "0" (0),                                    \
                         "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__ ("movq %%fs:%P1,%0"                              \
                         : "=r" (__value)                            \
                         : "i" (offsetof (struct _pthread_descr_struct,    \
                                        member)));                          \
    }                                                                \
  __value;                                                           \
})

Definition at line 101 of file pt-machine.h.

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

Definition at line 131 of file pt-machine.h.

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

Definition at line 81 of file pt-machine.h.

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

Definition at line 161 of file pt-machine.h.

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

Definition at line 188 of file pt-machine.h.


Function Documentation

int __arch_prctl ( int  __code,
unsigned long  __addr 
)
register char* stack_pointer __asm__ ( "%rsp"  )
int __compare_and_swap ( long int p,
long int  oldval,
long int  newval 
) [inline]

Definition at line 100 of file pt-machine.h.

{
  long int ret;

  __asm__ __volatile__ (
       "/* Inline compare & swap */\n"
       "1:\t"
       "ldq_l %0,%4\n\t"
       "cmpeq %0,%2,%0\n\t"
       "beq %0,2f\n\t"
       "mov %3,%0\n\t"
       "stq_c %0,%1\n\t"
       "beq %0,1b\n\t"
       "2:\tmb\n"
       "/* End compare & swap */"
       : "=&r"(ret), "=m"(*p)
       : "r"(oldval), "r"(newval), "m"(*p)
        : "memory");

  return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

long int testandset ( int spinlock)

Definition at line 53 of file pt-machine.h.

{
  long int ret, temp;

  __asm__ __volatile__(
       "/* Inline spinlock test & set */\n"
       "1:\t"
       "ldl_l %0,%3\n\t"
       "bne %0,2f\n\t"
       "or $31,1,%1\n\t"
       "stl_c %1,%2\n\t"
       "beq %1,1b\n"
       "2:\tmb\n"
       "/* End spinlock test & set */"
       : "=&r"(ret), "=&r"(temp), "=m"(*spinlock)
       : "m"(*spinlock)
        : "memory");

  return ret;
}