Back to index

glibc  2.9
Defines | Functions
pt-machine.h File Reference
#include <kernel-features.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   __builtin_frame_address (0)
#define HAS_COMPARE_AND_SWAP
#define TEST_FOR_COMPARE_AND_SWAP
#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)
PT_EI int get_eflags (void)
PT_EI void set_eflags (int newflags)
PT_EI int compare_and_swap_is_available (void)

Define Documentation

#define BUSY_WAIT_NOP   __asm__ ("rep; nop")

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

#define CURRENT_STACK_FRAME   __builtin_frame_address (0)

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

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

#define PT_EI   extern inline __attribute__ ((always_inline))

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

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


Function Documentation

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;
}

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

{
  int oldflags = get_eflags ();
  int changed;
  /* Flip AC bit in EFLAGS.  */
  set_eflags (oldflags ^ 0x40000);
  /* See if bit changed.  */
  changed = (get_eflags () ^ oldflags) & 0x40000;
  /* Restore EFLAGS.  */
  set_eflags (oldflags);
  /* If the AC flag did not change, it's a 386 and it lacks cmpxchg.
     Otherwise, it's a 486 or above and it has cmpxchg.  */
  return changed != 0;
}

Here is the call graph for this function:

PT_EI int get_eflags ( void  )

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

{
  int res;
  __asm__ __volatile__ ("pushfl; popl %0" : "=r" (res) : );
  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PT_EI void set_eflags ( int  newflags)

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

{
  __asm__ __volatile__ ("pushl %0; popfl" : : "r" (newflags) : "cc");
}

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;
}