123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- #pragma once
- #include <common/sys/types.h>
- #include <common/spinlock.h>
- #if ARCH(X86_64)
- #define __LOCKREF_ENABLE_CMPXCHG__
- #endif
- struct lockref
- {
- union
- {
- #ifdef __LOCKREF_ENABLE_CMPXCHG__
- aligned_u64 lock_count;
- #endif
- struct
- {
- spinlock_t lock;
- int count;
- };
- };
- };
- void lockref_inc(struct lockref *lock_ref);
- bool lockref_inc_not_zero(struct lockref *lock_ref);
- int lockref_dec(struct lockref *lock_ref);
- int lockref_dec_return(struct lockref *lock_ref);
- bool lockref_dec_not_zero(struct lockref *lock_ref);
- bool lockref_dec_or_lock_not_zero(struct lockref *lock_ref);
- void lockref_mark_dead(struct lockref * lock_ref);
- bool lockref_inc_not_dead(struct lockref *lock_ref);
|