diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2000-03-23 11:07:35 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2000-03-23 11:07:35 +0000 |
commit | 3fb72214e03d02f76ad6c4019cc6732b78968057 (patch) | |
tree | 654eae1ef0e72287e6c06392d0db469e870ec05b | |
parent | 16e2f0257d583379f6807177c40d65242c7294b3 (diff) |
Provide methods to check if a timeout was initalized and if it is scheduled.
-rw-r--r-- | sys/kern/kern_timeout.c | 6 | ||||
-rw-r--r-- | sys/sys/timeout.h | 16 |
2 files changed, 16 insertions, 6 deletions
diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c index f6274b691e5..7ef15bb9f82 100644 --- a/sys/kern/kern_timeout.c +++ b/sys/kern/kern_timeout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_timeout.c,v 1.2 2000/03/23 10:27:05 art Exp $ */ +/* $OpenBSD: kern_timeout.c,v 1.3 2000/03/23 11:07:34 art Exp $ */ /* * Copyright (c) 2000 Artur Grabowski <art@openbsd.org> * All rights reserved. @@ -100,7 +100,7 @@ timeout_set(to, fn, arg) to->to_func = fn; to->to_arg = arg; - to->to_flags = 0; + to->to_flags = TIMEOUT_INITIALIZED; } void @@ -237,7 +237,7 @@ timeout(fn, arg, to_ticks) timeout_list_unlock(s); timeout_set(to, fn, arg); - to->to_flags = TIMEOUT_STATIC; + to->to_flags |= TIMEOUT_STATIC; timeout_add(to, to_ticks); } diff --git a/sys/sys/timeout.h b/sys/sys/timeout.h index 9b3364dd2b3..aaec586706b 100644 --- a/sys/sys/timeout.h +++ b/sys/sys/timeout.h @@ -1,4 +1,4 @@ -/* $OpenBSD: timeout.h,v 1.1 2000/03/23 09:59:57 art Exp $ */ +/* $OpenBSD: timeout.h,v 1.2 2000/03/23 11:07:33 art Exp $ */ /* * Copyright (c) 2000 Artur Grabowski <art@openbsd.org> * All rights reserved. @@ -68,14 +68,24 @@ struct timeout { /* * flags in the to_flags field. */ -#define TIMEOUT_STATIC 1 /* allocated from static pool */ -#define TIMEOUT_ONQUEUE 2 /* timeout is on the todo queue */ +#define TIMEOUT_STATIC 1 /* allocated from static pool */ +#define TIMEOUT_ONQUEUE 2 /* timeout is on the todo queue */ +#define TIMEOUT_INITIALIZED 4 /* timeout is initialized */ void timeout_set __P((struct timeout *, void (*)(void *), void *)); void timeout_add __P((struct timeout *, int)); void timeout_del __P((struct timeout *)); /* + * special macros + * + * timeout_pending(to) - is this timeout already scheduled to run? + * timeout_initialized(to) - is this timeout initialized? + */ +#define timeout_pending(to) ((to)->to_flags & TIMEOUT_ONQUEUE) +#define timeout_initalized(to) ((to)->to_flags & TIMEOUT_INITIALIZED) + +/* * timeout_init - called by the machine dependent code to initialize a static * list of preallocated timeout structures. */ |