summaryrefslogtreecommitdiff
path: root/kern/sref_i.h
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2019-05-28 23:59:29 +0200
committerRichard Braun <rbraun@sceen.net>2019-05-28 23:59:29 +0200
commit096b2005752bce5c8bca1256dd4c5a42e0ec059c (patch)
treece18b12d88187d813d629d9bf6edb2b6da1a8980 /kern/sref_i.h
parentd44f65873b1a00f450346ac9506bcc65ecc2c5d5 (diff)
kern/sref: add optional debugging
Diffstat (limited to 'kern/sref_i.h')
-rw-r--r--kern/sref_i.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/kern/sref_i.h b/kern/sref_i.h
index 7b2b07f2..ebcb51d3 100644
--- a/kern/sref_i.h
+++ b/kern/sref_i.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2018 Richard Braun.
+ * Copyright (c) 2014-2019 Richard Braun.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,6 +24,10 @@
#include <kern/spinlock.h>
#include <kern/work.h>
+#ifdef CONFIG_SREF_DEBUG
+#define SREF_VERIFY
+#endif
+
#define SREF_WEAKREF_DYING ((uintptr_t)1)
#define SREF_WEAKREF_MASK (~SREF_WEAKREF_DYING)
@@ -42,8 +46,12 @@ struct sref_weakref {
uintptr_t addr;
};
-#define SREF_QUEUED 0x1
-#define SREF_DIRTY 0x2
+/*
+ * Counter flags.
+ */
+#define SREF_CNTF_QUEUED 0x1 /* Queued for review */
+#define SREF_CNTF_DIRTY 0x2 /* Dirty zero seen */
+#define SREF_CNTF_UNREF 0x4 /* Unreferenced, for debugging only */
/*
* Scalable reference counter.
@@ -60,7 +68,11 @@ struct sref_weakref {
struct sref_counter {
sref_noref_fn_t noref_fn;
+#ifdef SREF_VERIFY
+ struct {
+#else /* SREF_VERIFY */
union {
+#endif /* SREF_VERIFY */
struct {
struct slist_node node; /* (g) */
struct spinlock lock;