From: art Date: Thu, 23 Mar 2000 11:07:33 +0000 (+0000) Subject: Provide methods to check if a timeout was initalized and if it is scheduled. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=eeca01e3c226be5e232c0fa35f0a20623254c745;p=openbsd Provide methods to check if a timeout was initalized and if it is scheduled. --- 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 * 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 * All rights reserved. @@ -68,13 +68,23 @@ 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.