Commit 09d17960 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

atomic: add atomic_dec_and_test

This code is copied from the Linux kernel.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 834d996b
...@@ -46,4 +46,15 @@ typedef struct { ...@@ -46,4 +46,15 @@ typedef struct {
ret__; \ ret__; \
}) })
/* true if the result is 0, or false for all other cases. */
#define atomic_dec_and_test(mem) \
({ \
unsigned char ret__; \
asm volatile ("lock decl %0; sete %1\n" \
: "+m" ((mem)->counter), "=qm" (ret__) \
: \
: "cc", "memory"); \
ret__ != 0; \
})
#endif /* ATOMIC_H__ */ #endif /* ATOMIC_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment