summaryrefslogtreecommitdiff
path: root/kern/sref.c
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2018-02-06 20:45:45 +0100
committerRichard Braun <rbraun@sceen.net>2018-02-07 01:08:53 +0100
commitc04a26ee892d440979a84b891d6fac14cd4686f1 (patch)
tree0f59f0c1258f694d8a460e2ae6a874e8b002fa56 /kern/sref.c
parent6db72a1aeaddf038b12490fe9310a10693ffbf7a (diff)
kern/sref: allow custom initial values
Diffstat (limited to 'kern/sref.c')
-rw-r--r--kern/sref.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/kern/sref.c b/kern/sref.c
index 404d993..f145f80 100644
--- a/kern/sref.c
+++ b/kern/sref.c
@@ -991,13 +991,16 @@ sref_report_periodic_event(void)
void
sref_counter_init(struct sref_counter *counter,
+ unsigned long init_value,
struct sref_weakref *weakref,
sref_noref_fn_t noref_fn)
{
+ assert(init_value != 0);
+
counter->noref_fn = noref_fn;
spinlock_init(&counter->lock);
counter->flags = 0;
- counter->value = 1;
+ counter->value = init_value;
counter->weakref = weakref;
if (weakref) {