Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v4.16-rc5 48 lines 1.0 kB view raw
1/* SPDX-License-Identifier: GPL-2.0 */ 2#ifndef _ASM_SCORE_CMPXCHG_H 3#define _ASM_SCORE_CMPXCHG_H 4 5#include <linux/irqflags.h> 6 7struct __xchg_dummy { unsigned long a[100]; }; 8#define __xg(x) ((struct __xchg_dummy *)(x)) 9 10static inline 11unsigned long __xchg(volatile unsigned long *m, unsigned long val) 12{ 13 unsigned long retval; 14 unsigned long flags; 15 16 local_irq_save(flags); 17 retval = *m; 18 *m = val; 19 local_irq_restore(flags); 20 return retval; 21} 22 23#define xchg(ptr, v) \ 24 ((__typeof__(*(ptr))) __xchg((unsigned long *)(ptr), \ 25 (unsigned long)(v))) 26 27static inline unsigned long __cmpxchg(volatile unsigned long *m, 28 unsigned long old, unsigned long new) 29{ 30 unsigned long retval; 31 unsigned long flags; 32 33 local_irq_save(flags); 34 retval = *m; 35 if (retval == old) 36 *m = new; 37 local_irq_restore(flags); 38 return retval; 39} 40 41#define cmpxchg(ptr, o, n) \ 42 ((__typeof__(*(ptr))) __cmpxchg((unsigned long *)(ptr), \ 43 (unsigned long)(o), \ 44 (unsigned long)(n))) 45 46#include <asm-generic/cmpxchg-local.h> 47 48#endif /* _ASM_SCORE_CMPXCHG_H */