From 392e8802486cb573b916e746010e141a75f507e6 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 15 Nov 2014 09:58:27 +0800 Subject: init android origin source code --- .../arch/microblaze/include/asm/cmpxchg.h | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 ANDROID_3.4.5/arch/microblaze/include/asm/cmpxchg.h (limited to 'ANDROID_3.4.5/arch/microblaze/include/asm/cmpxchg.h') diff --git a/ANDROID_3.4.5/arch/microblaze/include/asm/cmpxchg.h b/ANDROID_3.4.5/arch/microblaze/include/asm/cmpxchg.h new file mode 100644 index 00000000..538afc0a --- /dev/null +++ b/ANDROID_3.4.5/arch/microblaze/include/asm/cmpxchg.h @@ -0,0 +1,42 @@ +#ifndef _ASM_MICROBLAZE_CMPXCHG_H +#define _ASM_MICROBLAZE_CMPXCHG_H + +#include + +void __bad_xchg(volatile void *ptr, int size); + +static inline unsigned long __xchg(unsigned long x, volatile void *ptr, + int size) +{ + unsigned long ret; + unsigned long flags; + + switch (size) { + case 1: + local_irq_save(flags); + ret = *(volatile unsigned char *)ptr; + *(volatile unsigned char *)ptr = x; + local_irq_restore(flags); + break; + + case 4: + local_irq_save(flags); + ret = *(volatile unsigned long *)ptr; + *(volatile unsigned long *)ptr = x; + local_irq_restore(flags); + break; + default: + __bad_xchg(ptr, size), ret = 0; + break; + } + + return ret; +} + +#define xchg(ptr, x) \ + ((__typeof__(*(ptr))) __xchg((unsigned long)(x), (ptr), sizeof(*(ptr)))) + +#include +#include + +#endif /* _ASM_MICROBLAZE_CMPXCHG_H */ -- cgit