mirror of
https://github.com/torvalds/linux.git
synced 2024-12-07 19:41:31 +00:00
d12157efc8
Most architectures define the atomic/atomic64 xchg and cmpxchg operations in terms of arch_xchg and arch_cmpxchg respectfully. Add fallbacks for these cases and remove the trivial cases from arch code. On some architectures the existing definitions are kept as these are used to build other arch_atomic*() operations. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/20230605070124.3741859-5-mark.rutland@arm.com
36 lines
693 B
C
36 lines
693 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __ASM_SH_ATOMIC_H
|
|
#define __ASM_SH_ATOMIC_H
|
|
|
|
#if defined(CONFIG_CPU_J2)
|
|
|
|
#include <asm-generic/atomic.h>
|
|
|
|
#else
|
|
|
|
/*
|
|
* Atomic operations that C can't guarantee us. Useful for
|
|
* resource counting etc..
|
|
*
|
|
*/
|
|
|
|
#include <linux/compiler.h>
|
|
#include <linux/types.h>
|
|
#include <asm/cmpxchg.h>
|
|
#include <asm/barrier.h>
|
|
|
|
#define arch_atomic_read(v) READ_ONCE((v)->counter)
|
|
#define arch_atomic_set(v,i) WRITE_ONCE((v)->counter, (i))
|
|
|
|
#if defined(CONFIG_GUSA_RB)
|
|
#include <asm/atomic-grb.h>
|
|
#elif defined(CONFIG_CPU_SH4A)
|
|
#include <asm/atomic-llsc.h>
|
|
#else
|
|
#include <asm/atomic-irq.h>
|
|
#endif
|
|
|
|
#endif /* CONFIG_CPU_J2 */
|
|
|
|
#endif /* __ASM_SH_ATOMIC_H */
|