diff options
Diffstat (limited to 'include/linux/refcount.h')
| -rw-r--r-- | include/linux/refcount.h | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/include/linux/refcount.h b/include/linux/refcount.h index a685da2c4522..e28cce21bad6 100644 --- a/include/linux/refcount.h +++ b/include/linux/refcount.h | |||
| @@ -3,9 +3,10 @@ | |||
| 3 | #define _LINUX_REFCOUNT_H | 3 | #define _LINUX_REFCOUNT_H |
| 4 | 4 | ||
| 5 | #include <linux/atomic.h> | 5 | #include <linux/atomic.h> |
| 6 | #include <linux/mutex.h> | 6 | #include <linux/compiler.h> |
| 7 | #include <linux/spinlock.h> | 7 | #include <linux/spinlock_types.h> |
| 8 | #include <linux/kernel.h> | 8 | |
| 9 | struct mutex; | ||
| 9 | 10 | ||
| 10 | /** | 11 | /** |
| 11 | * struct refcount_t - variant of atomic_t specialized for reference counts | 12 | * struct refcount_t - variant of atomic_t specialized for reference counts |
| @@ -42,17 +43,30 @@ static inline unsigned int refcount_read(const refcount_t *r) | |||
| 42 | return atomic_read(&r->refs); | 43 | return atomic_read(&r->refs); |
| 43 | } | 44 | } |
| 44 | 45 | ||
| 46 | extern __must_check bool refcount_add_not_zero_checked(unsigned int i, refcount_t *r); | ||
| 47 | extern void refcount_add_checked(unsigned int i, refcount_t *r); | ||
| 48 | |||
| 49 | extern __must_check bool refcount_inc_not_zero_checked(refcount_t *r); | ||
| 50 | extern void refcount_inc_checked(refcount_t *r); | ||
| 51 | |||
| 52 | extern __must_check bool refcount_sub_and_test_checked(unsigned int i, refcount_t *r); | ||
| 53 | |||
| 54 | extern __must_check bool refcount_dec_and_test_checked(refcount_t *r); | ||
| 55 | extern void refcount_dec_checked(refcount_t *r); | ||
| 56 | |||
| 45 | #ifdef CONFIG_REFCOUNT_FULL | 57 | #ifdef CONFIG_REFCOUNT_FULL |
| 46 | extern __must_check bool refcount_add_not_zero(unsigned int i, refcount_t *r); | ||
| 47 | extern void refcount_add(unsigned int i, refcount_t *r); | ||
| 48 | 58 | ||
| 49 | extern __must_check bool refcount_inc_not_zero(refcount_t *r); | 59 | #define refcount_add_not_zero refcount_add_not_zero_checked |
| 50 | extern void refcount_inc(refcount_t *r); | 60 | #define refcount_add refcount_add_checked |
| 61 | |||
| 62 | #define refcount_inc_not_zero refcount_inc_not_zero_checked | ||
| 63 | #define refcount_inc refcount_inc_checked | ||
| 64 | |||
| 65 | #define refcount_sub_and_test refcount_sub_and_test_checked | ||
| 51 | 66 | ||
| 52 | extern __must_check bool refcount_sub_and_test(unsigned int i, refcount_t *r); | 67 | #define refcount_dec_and_test refcount_dec_and_test_checked |
| 68 | #define refcount_dec refcount_dec_checked | ||
| 53 | 69 | ||
| 54 | extern __must_check bool refcount_dec_and_test(refcount_t *r); | ||
| 55 | extern void refcount_dec(refcount_t *r); | ||
| 56 | #else | 70 | #else |
| 57 | # ifdef CONFIG_ARCH_HAS_REFCOUNT | 71 | # ifdef CONFIG_ARCH_HAS_REFCOUNT |
| 58 | # include <asm/refcount.h> | 72 | # include <asm/refcount.h> |
