similar to TASK_INITIALIZER and all the queue _INITIALIZER things.
ok deraadt@
-# $OpenBSD: Makefile,v 1.225 2014/12/11 14:29:42 jmc Exp $
+# $OpenBSD: Makefile,v 1.226 2014/12/22 04:43:38 dlg Exp $
# $NetBSD: Makefile,v 1.4 1996/01/09 03:23:01 thorpej Exp $
# Makefile for section 9 (kernel function and variable) manual pages.
timeout.9 timeout_add_sec.9 \
timeout.9 timeout_add_msec.9 \
timeout.9 timeout_add_usec.9 \
- timeout.9 timeout_add_nsec.9
+ timeout.9 timeout_add_nsec.9 \
+ timeout.9 TIMEOUT_INITIALIZER.9
MLINKS+=tsleep.9 wakeup.9 tsleep.9 wakeup_n.9 tsleep.9 wakeup_one.9 \
tsleep.9 msleep.9
MLINKS+=tvtohz.9 tstohz.9
-.\" $OpenBSD: timeout.9,v 1.37 2014/02/13 14:20:07 jmc Exp $
+.\" $OpenBSD: timeout.9,v 1.38 2014/12/22 04:43:38 dlg Exp $
.\"
.\" Copyright (c) 2000 Artur Grabowski <art@openbsd.org>
.\" All rights reserved.
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd $Mdocdate: February 13 2014 $
+.Dd $Mdocdate: December 22 2014 $
.Dt TIMEOUT 9
.Os
.Sh NAME
.Nm timeout_del ,
.Nm timeout_pending ,
.Nm timeout_initialized ,
-.Nm timeout_triggered
+.Nm timeout_triggered ,
+.Nm TIMEOUT_INITIALIZER
.Nd execute a function after a specified period of time
.Sh SYNOPSIS
.In sys/types.h
.Fn "timeout_add_usec" "struct timeout *to" "int usec"
.Ft int
.Fn "timeout_add_nsec" "struct timeout *to" "int nsec"
+.Fn "TIMEOUT_INITIALIZER" "void (*fn)(void *)" "void *arg"
.Sh DESCRIPTION
The
.Nm timeout
.Fn timeout_add .
Those functions add a timeout whilst converting the time specified
by the respective types.
+.Pp
+A timeout declaration can be initialised with the
+.Fn TIMEOUT_INITIALIZER
+macro.
+The timeout will be prepared to call the function specified by the
+.Fa fn
+argument with the
+.Fa void *
+argument given in
+.Fa arg .
.Sh CONTEXT
.Fn timeout_set
can be called during autoconf, from process context, or from interrupt
-/* $OpenBSD: timeout.h,v 1.24 2013/11/27 04:28:32 dlg Exp $ */
+/* $OpenBSD: timeout.h,v 1.25 2014/12/22 04:43:38 dlg Exp $ */
/*
* Copyright (c) 2000-2001 Artur Grabowski <art@openbsd.org>
* All rights reserved.
#define timeout_initialized(to) ((to)->to_flags & TIMEOUT_INITIALIZED)
#define timeout_triggered(to) ((to)->to_flags & TIMEOUT_TRIGGERED)
+#define TIMEOUT_INITIALIZER(_f, _a) \
+ { { NULL, NULL }, (_f), (_a), 0, TIMEOUT_INITIALIZED }
+
struct bintime;
void timeout_set(struct timeout *, void (*)(void *), void *);