Back to index

glibc  2.9
Defines | Functions
pt-machine.h File Reference

Go to the source code of this file.

Defines

#define PT_EI   extern inline __attribute__ ((always_inline))
#define MEMORY_BARRIER()   __asm__ __volatile__ ("lwsync" : : : "memory")
#define READ_MEMORY_BARRIER()   __asm__ __volatile__ ("lwsync" : : : "memory")
#define WRITE_MEMORY_BARRIER()   __asm__ __volatile__ ("eieio" : : : "memory")
#define FLOATING_STACKS   1
#define ARCH_STACK_MAX_SIZE   16*1024*1024
#define CURRENT_STACK_FRAME   stack_pointer
#define THREAD_SELF   __thread_self
#define INIT_THREAD_SELF(descr, nr)   (__thread_self = (descr))
#define THREAD_GETMEM(descr, member)   ((void) (descr), THREAD_SELF->member)
#define THREAD_GETMEM_NC(descr, member)   ((void) (descr), THREAD_SELF->member)
#define THREAD_SETMEM(descr, member, value)   ((void) (descr), THREAD_SELF->member = (value))
#define THREAD_SETMEM_NC(descr, member, value)   ((void) (descr), THREAD_SELF->member = (value))
#define HAS_COMPARE_AND_SWAP
#define HAS_COMPARE_AND_SWAP_WITH_RELEASE_SEMANTICS

Functions

long int testandset (int *spinlock)
int __compare_and_swap (long int *p, long int oldval, long int newval)
int __compare_and_swap32 (int *p, int oldval, int newval)
register char *stack_pointer __asm__ ("r1")
register struct
_pthread_descr_struct
*__thread_self 
__asm__ ("r13")
PT_EI int __compare_and_swap_with_release_semantics (long int *p, long int oldval, long int newval)
PT_EI int __compare_and_swap32_with_release_semantics (long int *p, long int oldval, long int newval)

Define Documentation

#define ARCH_STACK_MAX_SIZE   16*1024*1024

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

#define CURRENT_STACK_FRAME   stack_pointer

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

#define FLOATING_STACKS   1

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

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

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

#define INIT_THREAD_SELF (   descr,
  nr 
)    (__thread_self = (descr))

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

#define MEMORY_BARRIER ( )    __asm__ __volatile__ ("lwsync" : : : "memory")

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

#define PT_EI   extern inline __attribute__ ((always_inline))

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

#define READ_MEMORY_BARRIER ( )    __asm__ __volatile__ ("lwsync" : : : "memory")

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

#define THREAD_GETMEM (   descr,
  member 
)    ((void) (descr), THREAD_SELF->member)

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

#define THREAD_GETMEM_NC (   descr,
  member 
)    ((void) (descr), THREAD_SELF->member)

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

#define THREAD_SELF   __thread_self

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

#define THREAD_SETMEM (   descr,
  member,
  value 
)    ((void) (descr), THREAD_SELF->member = (value))

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

#define THREAD_SETMEM_NC (   descr,
  member,
  value 
)    ((void) (descr), THREAD_SELF->member = (value))

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

#define WRITE_MEMORY_BARRIER ( )    __asm__ __volatile__ ("eieio" : : : "memory")

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


Function Documentation

register char* stack_pointer __asm__ ( "r1"  )
register struct _pthread_descr_struct* __thread_self __asm__ ( "r13"  ) [read]
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;
}
PT_EI int __compare_and_swap32 ( int p,
int  oldval,
int  newval 
)

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

{
  int ret;

  __asm__ __volatile__ (
          "0:    lwarx %0,0,%1 ;"
          "      xor. %0,%3,%0;"
          "      bne 1f;"
          "      stwcx. %2,0,%1;"
          "      bne- 0b;"
          "1:    "
       : "=&r"(ret)
       : "r"(p), "r"(newval), "r"(oldval)
       : "cr0", "memory");
  /* This version of __compare_and_swap is to be used when acquiring
     a lock, so we don't need to worry about whether other memory
     operations have completed, but we do need to be sure that any loads
     after this point really occur after we have acquired the lock.  */
  __asm__ __volatile__ ("isync" : : : "memory");
  return (int)(ret == 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PT_EI int __compare_and_swap32_with_release_semantics ( long int p,
long int  oldval,
long int  newval 
)

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

{
  long int ret;

  MEMORY_BARRIER ();
  __asm__ __volatile__ (
          "0:    lwarx %0,0,%1 ;"
          "      xor. %0,%3,%0;"
          "      bne 1f;"
          "      stwcx. %2,0,%1;"
          "      bne- 0b;"
          "1:    "
       : "=&r"(ret)
       : "r"(p), "r"(newval), "r"(oldval)
       : "cr0", "memory");
  return (int)(ret == 0);
}

Here is the call graph for this function:

PT_EI int __compare_and_swap_with_release_semantics ( long int p,
long int  oldval,
long int  newval 
)

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

{
  long int ret;

  MEMORY_BARRIER ();
  __asm__ __volatile__ (
          "0:    ldarx %0,0,%1 ;"
          "      xor. %0,%3,%0;"
          "      bne 1f;"
          "      stdcx. %2,0,%1;"
          "      bne- 0b;"
          "1:    "
       : "=&r"(ret)
       : "r"(p), "r"(newval), "r"(oldval)
       : "cr0", "memory");
  return (int)(ret == 0);
}

Here is the call 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;
}