2 * Copyright (C) 2004 Microtronix Datacom Ltd.
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
9 #ifndef _ASM_NIOS2_CMPXCHG_H
10 #define _ASM_NIOS2_CMPXCHG_H
12 #include <linux/irqflags.h>
14 #define xchg(ptr, x) \
15 ((__typeof__(*(ptr)))__xchg((unsigned long)(x), (ptr), sizeof(*(ptr))))
17 struct __xchg_dummy
{ unsigned long a
[100]; };
18 #define __xg(x) ((volatile struct __xchg_dummy *)(x))
20 static inline unsigned long __xchg(unsigned long x
, volatile void *ptr
,
23 unsigned long tmp
, flags
;
25 local_irq_save(flags
);
33 : "r" (x
), "m" (*__xg(ptr
))
41 : "r" (x
), "m" (*__xg(ptr
))
49 : "r" (x
), "m" (*__xg(ptr
))
54 local_irq_restore(flags
);
58 #include <asm-generic/cmpxchg.h>
59 #include <asm-generic/cmpxchg-local.h>
61 #endif /* _ASM_NIOS2_CMPXCHG_H */