[Spice-devel] [PATCH 07/12] server: use gcc builtin for atomic get/set bit
Christophe Fergeau
cfergeau at redhat.com
Fri Apr 22 09:43:05 PDT 2011
---
server/red_worker.h | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/server/red_worker.h b/server/red_worker.h
index ae2eaee..b4e2ed2 100644
--- a/server/red_worker.h
+++ b/server/red_worker.h
@@ -23,12 +23,14 @@
static inline void set_bit(int index, uint32_t *addr)
{
- __asm__ __volatile__ ("lock btsl %1, %0": : "m" (*addr), "r" (index));
+ uint32_t mask = 1 << index;
+ __sync_or_and_fetch(addr, mask);
}
static inline void clear_bit(int index, uint32_t *addr)
{
- __asm__ __volatile__ ("lock btrl %1, %0": : "m" (*addr), "r" (index));
+ uint32_t mask = ~(1 << index);
+ __sync_and_and_fetch(addr, mask);
}
static inline int test_bit(int index, uint32_t val)
--
1.7.4.4
More information about the Spice-devel
mailing list