Add missing atomic64 compat helpers for 32-bit systems.

The use of these functions was added with the recent atomic work
and not tested on 32-bit systems.  Add the missing compat functions:
atomic64_inc, atomic64_dec, atomic64_add_return, atomic64_sub_return,
atomic64_inc_return, atomic64_dec_return.
This commit is contained in:
Brian Behlendorf 2009-12-01 10:15:27 -08:00
parent 6ff686c44d
commit a5d6f6020a
1 changed files with 32 additions and 0 deletions

View File

@ -32,6 +32,38 @@ static inline void atomic64_sub(__s64 i, atomic64_t *v)
spin_unlock_irqrestore(&v->lock, flags);
}
#define atomic64_inc(v) (atomic64_add(1, (v)))
#define atomic64_dec(v) (atomic64_sub(1, (v)))
static inline __s64 atomic64_add_return(__s64 i, atomic64_t *v)
{
unsigned long flags;
__s64 ret;
spin_lock_irqsave(&v->lock, flags);
v->val += i;
ret = v->val;
spin_unlock_irqrestore(&v->lock, flags);
return ret;
}
static inline __s64 atomic64_sub_return(__s64 i, atomic64_t *v)
{
unsigned long flags;
__s64 ret;
spin_lock_irqsave(&v->lock, flags);
v->val -= i;
ret = v->val;
spin_unlock_irqrestore(&v->lock, flags);
return ret;
}
#define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
#define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
static inline __s64 atomic64_read(atomic64_t *v)
{
unsigned long flags;