diff options
author | Brian Behlendorf <[email protected]> | 2009-12-01 10:15:27 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2009-12-01 10:15:27 -0800 |
commit | a5d6f6020aeeebfabd0bb5e48d8736d63b44b875 (patch) | |
tree | 1cfa0cc38c5c2f891f93c39786cc85af0d0019a6 /include | |
parent | 6ff686c44dbc39f12cb57e930fb20199203514d9 (diff) |
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.
Diffstat (limited to 'include')
-rw-r--r-- | include/asm/atomic_compat.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/include/asm/atomic_compat.h b/include/asm/atomic_compat.h index c769d6248..5eaccd7e7 100644 --- a/include/asm/atomic_compat.h +++ b/include/asm/atomic_compat.h @@ -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; |