Пример #1
0
void HIDDEN
__sync_lock_release_4 (int *ptr)
{
  int failure, oldval;

  do {
    oldval = *ptr;
    failure = __kernel_cmpxchg (oldval, 0, ptr);
  } while (failure != 0);
}
Пример #2
0
int HIDDEN
__sync_lock_test_and_set_4 (int *ptr, int val)
{
int failure, oldval;
do {
oldval = *ptr;
failure = __kernel_cmpxchg (oldval, val, ptr);
} while (failure != 0);
return oldval;
}
Пример #3
0
int HIDDEN
__sync_val_compare_and_swap_4 (int *ptr, int oldval, int newval)
{
  int actual_oldval, fail;

  while (1)
    {
      actual_oldval = *ptr;
      if (__builtin_expect (oldval != actual_oldval, 0))
        return actual_oldval;
      fail = __kernel_cmpxchg (actual_oldval, newval, ptr);

      if (__builtin_expect (!fail, 1))
        return oldval;
    }
 }
Пример #4
0
bool HIDDEN
__sync_bool_compare_and_swap_4 (int *ptr, int oldval, int newval)
{
  int failure = __kernel_cmpxchg (oldval, newval, ptr);
  return (failure == 0);
}
Пример #5
0
bool HIDDEN
__sync_bool_compare_and_swap_4 (unsigned *ptr, unsigned oldval,
				unsigned newval)
{
  return __kernel_cmpxchg (ptr, oldval, newval) == oldval;
}