Index: sys/sys/timeout.h =================================================================== RCS file: /cvs/src/sys/sys/timeout.h,v retrieving revision 1.24 diff -u -p -r1.24 timeout.h --- sys/sys/timeout.h 27 Nov 2013 04:28:32 -0000 1.24 +++ sys/sys/timeout.h 22 Dec 2014 03:54:53 -0000 @@ -82,6 +82,9 @@ struct timeout { #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 *); Index: share/man/man9/timeout.9 =================================================================== RCS file: /cvs/src/share/man/man9/timeout.9,v retrieving revision 1.37 diff -u -p -r1.37 timeout.9 --- share/man/man9/timeout.9 13 Feb 2014 14:20:07 -0000 1.37 +++ share/man/man9/timeout.9 22 Dec 2014 03:54:53 -0000 @@ -39,7 +39,8 @@ .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 @@ -70,6 +71,7 @@ .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 @@ -173,6 +175,16 @@ functions instead of .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 Index: share/man/man9/Makefile =================================================================== RCS file: /cvs/src/share/man/man9/Makefile,v retrieving revision 1.222 diff -u -p -r1.222 Makefile --- share/man/man9/Makefile 4 Nov 2014 23:27:02 -0000 1.222 +++ share/man/man9/Makefile 22 Dec 2014 03:54:53 -0000 @@ -386,7 +386,8 @@ MLINKS+=timeout.9 timeout_add.9 timeout. 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