diff options
author | Takashi Iwai <tiwai@suse.de> | 2022-01-08 12:07:49 +0100 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2022-01-08 12:07:49 +0100 |
commit | db2803ca9694d2a500e5ac56970b3530db7da826 (patch) | |
tree | a9c4041a6f2e847c17d9bde3650e3b85ce4e10d7 | |
parent | 69196562b596478cdc9c05f1dab03ec8ac63ae13 (diff) | |
download | hda-emu-db2803ca9694d2a500e5ac56970b3530db7da826.tar.gz |
Add linux/refcount.h wrapper
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | include/linux/refcount.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/linux/refcount.h b/include/linux/refcount.h new file mode 100644 index 0000000..a59397b --- /dev/null +++ b/include/linux/refcount.h @@ -0,0 +1,19 @@ +#ifndef _LINUX_REFCOUNT_H +#define _LINUX_REFCOUNT_H + +#include "atomic.h" + +#define refcount_t atomic_t + +#define REFCOUNT_INIT(n) ATOMIC_INIT(n) +#define refcount_set(r, n) atomic_set((r), (n)) +#define refcount_read(r) atomic_read(r) +#define refcount_inc(r) atomic_inc(r) +#define refcount_dec(r) atomic_dec(r) + +static inline bool refcount_dec_and_test(refcount_t *r) +{ + refcount_dec(r); + return !refcount_read(r); +} +#endif |