lib: Provide an atomic exchange function unsigned long
Signed-off-by: Anup Patel <anup.patel@wdc.com> Signed-off-by: Atish Patra <atish.patra@wdc.com>
This commit is contained in:
parent
a88e424f6c
commit
f6e13e0dd3
|
@ -35,6 +35,9 @@ long arch_atomic_xchg(atomic_t *atom, long newval);
|
||||||
|
|
||||||
unsigned int atomic_raw_xchg_uint(volatile unsigned int *ptr,
|
unsigned int atomic_raw_xchg_uint(volatile unsigned int *ptr,
|
||||||
unsigned int newval);
|
unsigned int newval);
|
||||||
|
|
||||||
|
unsigned long atomic_raw_xchg_ulong(volatile unsigned long *ptr,
|
||||||
|
unsigned long newval);
|
||||||
/**
|
/**
|
||||||
* Set a bit in an atomic variable and return the new value.
|
* Set a bit in an atomic variable and return the new value.
|
||||||
* @nr : Bit to set.
|
* @nr : Bit to set.
|
||||||
|
|
|
@ -175,6 +175,22 @@ unsigned int atomic_raw_xchg_uint(volatile unsigned int *ptr,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned long atomic_raw_xchg_ulong(volatile unsigned long *ptr,
|
||||||
|
unsigned long newval)
|
||||||
|
{
|
||||||
|
/* Atomically set new value and return old value. */
|
||||||
|
#ifdef __riscv_atomic
|
||||||
|
/*
|
||||||
|
* The name of GCC built-in macro __sync_lock_test_and_set()
|
||||||
|
* is misleading. A more appropriate name for GCC built-in
|
||||||
|
* macro would be __sync_val_exchange().
|
||||||
|
*/
|
||||||
|
return __sync_lock_test_and_set(ptr, newval);
|
||||||
|
#else
|
||||||
|
return xchg(ptr, newval);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#if (BITS_PER_LONG == 64)
|
#if (BITS_PER_LONG == 64)
|
||||||
#define __AMO(op) "amo" #op ".d"
|
#define __AMO(op) "amo" #op ".d"
|
||||||
#elif (BITS_PER_LONG == 32)
|
#elif (BITS_PER_LONG == 32)
|
||||||
|
|
Loading…
Reference in New Issue