mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 13:55:32 +00:00
![Linus Torvalds](/assets/img/avatar_default.png)
They aren't very good to inline, since they already call external functions (the spinlock code), and we're going to create rather more complicated versions of them that can do the reference count updates locklessly. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
29 lines
907 B
C
29 lines
907 B
C
#ifndef __LINUX_LOCKREF_H
|
|
#define __LINUX_LOCKREF_H
|
|
|
|
/*
|
|
* Locked reference counts.
|
|
*
|
|
* These are different from just plain atomic refcounts in that they
|
|
* are atomic with respect to the spinlock that goes with them. In
|
|
* particular, there can be implementations that don't actually get
|
|
* the spinlock for the common decrement/increment operations, but they
|
|
* still have to check that the operation is done semantically as if
|
|
* the spinlock had been taken (using a cmpxchg operation that covers
|
|
* both the lock and the count word, or using memory transactions, for
|
|
* example).
|
|
*/
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
struct lockref {
|
|
spinlock_t lock;
|
|
unsigned int count;
|
|
};
|
|
|
|
extern void lockref_get(struct lockref *);
|
|
extern int lockref_get_not_zero(struct lockref *);
|
|
extern int lockref_get_or_lock(struct lockref *);
|
|
extern int lockref_put_or_lock(struct lockref *);
|
|
|
|
#endif /* __LINUX_LOCKREF_H */
|