diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_timeout.c | 17 | ||||
-rw-r--r-- | sys/sys/timeout.h | 13 |
2 files changed, 19 insertions, 11 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 diff --git a/sys/sys/timeout.h b/sys/sys/timeout.h index 88c0cb7c5e4..1cd9fca9e06 100644 --- a/sys/sys/timeout.h +++ b/sys/sys/timeout.h @@ -1,4 +1,4 @@ -/* $OpenBSD: timeout.h,v 1.35 2020/01/03 01:16:12 cheloha Exp $ */ +/* $OpenBSD: timeout.h,v 1.36 2020/01/03 02:16:38 cheloha Exp $ */ /* * Copyright (c) 2000-2001 Artur Grabowski <art@openbsd.org> * All rights reserved. @@ -101,17 +101,20 @@ int timeout_sysctl(void *, size_t *, void *, size_t); #define timeout_initialized(to) ((to)->to_flags & TIMEOUT_INITIALIZED) #define timeout_triggered(to) ((to)->to_flags & TIMEOUT_TRIGGERED) -#define TIMEOUT_INITIALIZER(_f, _a) { \ +#define TIMEOUT_INITIALIZER_FLAGS(fn, arg, flags) { \ .to_list = { NULL, NULL }, \ - .to_func = (_f), \ - .to_arg = (_a), \ + .to_func = (fn), \ + .to_arg = (arg), \ .to_time = 0, \ - .to_flags = TIMEOUT_INITIALIZED \ + .to_flags = (flags) | TIMEOUT_INITIALIZED \ } +#define TIMEOUT_INITIALIZER(_f, _a) TIMEOUT_INITIALIZER_FLAGS((_f), (_a), 0) + struct bintime; void timeout_set(struct timeout *, void (*)(void *), void *); +void timeout_set_flags(struct timeout *, void (*)(void *), void *, int); void timeout_set_proc(struct timeout *, void (*)(void *), void *); int timeout_add(struct timeout *, int); int timeout_add_tv(struct timeout *, const struct timeval *); |