[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v7 2/8] arm: compile memshr
Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx> Acked-by: Ian Campbell <Ian.campbell@xxxxxxxxxx> Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> --- tools/memshr/bidir-hash.c | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-) diff --git a/tools/memshr/bidir-hash.c b/tools/memshr/bidir-hash.c index 6c0dc3d..45d473e 100644 --- a/tools/memshr/bidir-hash.c +++ b/tools/memshr/bidir-hash.c @@ -109,6 +109,37 @@ static void hash_resize(struct __hash *h); } while (0) static inline void atomic_inc(uint32_t *v) { ia64_fetchadd4_rel(v, 1); } static inline void atomic_dec(uint32_t *v) { ia64_fetchadd4_rel(v, -1); } +#elif defined(__arm__) +static inline void atomic_inc(uint32_t *v) +{ + unsigned long tmp; + int result; + + __asm__ __volatile__("@ atomic_add\n" +"1: ldrex %0, [%3]\n" +" add %0, %0, #1\n" +" strex %1, %0, [%3]\n" +" teq %1, #0\n" +" bne 1b" + : "=&r" (result), "=&r" (tmp), "+Qo" (*v) + : "r" (v) + : "cc"); +} +static inline void atomic_dec(uint32_t *v) +{ + unsigned long tmp; + int result; + + __asm__ __volatile__("@ atomic_sub\n" +"1: ldrex %0, [%3]\n" +" sub %0, %0, #1\n" +" strex %1, %0, [%3]\n" +" teq %1, #0\n" +" bne 1b" + : "=&r" (result), "=&r" (tmp), "+Qo" (*v) + : "r" (v) + : "cc"); +} #else /* __x86__ */ static inline void atomic_inc(uint32_t *v) { -- 1.7.2.5 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |