diff options
author | 2020-01-03 02:16:38 +0000 | |
---|---|---|
committer | 2020-01-03 02:16:38 +0000 | |
commit | d7434681e0f391166a38ab7ed973aaec997e6945 (patch) | |
tree | 26fe2f5c626423ed6b7212b6d12f37bd79a3ae45 /sys/kern/kern_timeout.c | |
parent | timeout(9): Rename the TIMEOUT_NEEDPROCCTX flag to TIMEOUT_PROC. (diff) | |
download | wireguard-openbsd-d7434681e0f391166a38ab7ed973aaec997e6945.tar.xz wireguard-openbsd-d7434681e0f391166a38ab7ed973aaec997e6945.zip |
timeout(9): Add timeout_set_flags(9) and TIMEOUT_INITIALIZER_FLAGS(9)
These allow the caller to initialize timeouts with arbitrary flags. We
only have one flag at the moment, TIMEOUT_PROC, but experimenting with
other flags is easier if these interfaces are available in-tree.
With input from bluhm@, guenther@, and visa@.
"makes sense to me" bluhm@, ok visa@
Diffstat (limited to 'sys/kern/kern_timeout.c')
-rw-r--r-- | sys/kern/kern_timeout.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c index 293659ac7aa..9239d8e5f8b 100644 --- a/sys/kern/kern_timeout.c +++ b/sys/kern/kern_timeout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_timeout.c,v 1.68 2020/01/03 01:16:12 cheloha Exp $ */ +/* $OpenBSD: kern_timeout.c,v 1.69 2020/01/03 02:16:38 cheloha Exp $ */ /* * Copyright (c) 2001 Thomas Nordin <nordin@openbsd.org> * Copyright (c) 2000-2001 Artur Grabowski <art@openbsd.org> @@ -224,16 +224,21 @@ timeout_proc_init(void) void timeout_set(struct timeout *new, void (*fn)(void *), void *arg) { - new->to_func = fn; - new->to_arg = arg; - new->to_flags = TIMEOUT_INITIALIZED; + timeout_set_flags(new, fn, arg, 0); +} + +void +timeout_set_flags(struct timeout *to, void (*fn)(void *), void *arg, int flags) +{ + to->to_func = fn; + to->to_arg = arg; + to->to_flags = flags | TIMEOUT_INITIALIZED; } void timeout_set_proc(struct timeout *new, void (*fn)(void *), void *arg) { - timeout_set(new, fn, arg); - SET(new->to_flags, TIMEOUT_PROC); + timeout_set_flags(new, fn, arg, TIMEOUT_PROC); } int |