lockref.h 907 B

1234567891011121314151617181920212223242526272829
  1. #ifndef __LINUX_LOCKREF_H
  2. #define __LINUX_LOCKREF_H
  3. /*
  4. * Locked reference counts.
  5. *
  6. * These are different from just plain atomic refcounts in that they
  7. * are atomic with respect to the spinlock that goes with them. In
  8. * particular, there can be implementations that don't actually get
  9. * the spinlock for the common decrement/increment operations, but they
  10. * still have to check that the operation is done semantically as if
  11. * the spinlock had been taken (using a cmpxchg operation that covers
  12. * both the lock and the count word, or using memory transactions, for
  13. * example).
  14. */
  15. #include <linux/spinlock.h>
  16. struct lockref {
  17. spinlock_t lock;
  18. unsigned int count;
  19. };
  20. extern void lockref_get(struct lockref *);
  21. extern int lockref_get_not_zero(struct lockref *);
  22. extern int lockref_get_or_lock(struct lockref *);
  23. extern int lockref_put_or_lock(struct lockref *);
  24. #endif /* __LINUX_LOCKREF_H */