1 #include <linux/spinlock.h>
2 #include <asm/atomic.h>
5 * This is an architecture-neutral, but slow,
6 * implementation of the notion of "decrement
7 * a reference count, and return locked if it
8 * decremented to zero".
10 * NOTE NOTE NOTE! This is _not_ equivalent to
12 * if (atomic_dec_and_test(&atomic)) {
18 * because the spin-lock and the decrement must be
21 * This slow version gets the spinlock unconditionally,
22 * and releases it if it isn't needed. Architectures
23 * are encouraged to come up with better approaches,
24 * this is trivially done efficiently using a load-locked
25 * store-conditional approach, for example.
28 #ifndef atomic_dec_and_lock
29 int atomic_dec_and_lock(atomic_t
*atomic
, spinlock_t
*lock
)
32 if (atomic_dec_and_test(atomic
))