-/* $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.
to->to_func = fn;
to->to_arg = arg;
- to->to_flags = 0;
+ to->to_flags = TIMEOUT_INITIALIZED;
}
void
timeout_list_unlock(s);
timeout_set(to, fn, arg);
- to->to_flags = TIMEOUT_STATIC;
+ to->to_flags |= TIMEOUT_STATIC;
timeout_add(to, to_ticks);
}
-/* $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.
/*
* 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.