Re: TIMEOUT_INITIALIZER

2014-12-21 Thread Ted Unangst
On Mon, Dec 22, 2014 at 13:56, David Gwynne wrote: > i keep writing code that uses this, cos i was sure i added it years > ago. turns out i havent. > > this is like TASK_INITIALIZER or the queue _INTIIALIZER macros. it > lets you init a declaration of a timeout. seems pretty obvious. timeout_set

TIMEOUT_INITIALIZER

2014-12-21 Thread David Gwynne
ags & 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/ma

Re: TIMEOUT_INITIALIZER() for src/sys/dev.c to avoid timeout_initialized()

2013-12-09 Thread Theo de Raadt
> On Mon, Dec 09, 2013 at 01:55:53PM +1000, David Gwynne wrote: > > this is a demonstration of using TIMEOUT_INITIALIZED(). > > > > because we know the timeout is always set up correctly, we dont > > have to test for it all over the place. > > > > [a bit of snipping...] > > > - if (timeout_in

Re: TIMEOUT_INITIALIZER() for src/sys/dev.c to avoid timeout_initialized()

2013-12-09 Thread Bret Lambert
On Mon, Dec 09, 2013 at 10:18:06PM +1000, David Gwynne wrote: > > On 9 Dec 2013, at 10:01 pm, David Gwynne wrote: > > > > > On 9 Dec 2013, at 6:59 pm, Bret Lambert wrote: > > > >> On Mon, Dec 09, 2013 at 01:55:53PM +1000, David Gwynne wrote: > >>> this is a demonstration of using TIMEOUT_INIT

Re: TIMEOUT_INITIALIZER() for src/sys/dev.c to avoid timeout_initialized()

2013-12-09 Thread David Gwynne
On 9 Dec 2013, at 10:01 pm, David Gwynne wrote: > > On 9 Dec 2013, at 6:59 pm, Bret Lambert wrote: > >> On Mon, Dec 09, 2013 at 01:55:53PM +1000, David Gwynne wrote: >>> this is a demonstration of using TIMEOUT_INITIALIZED(). >>> >>> because we know the timeout is always set up correctly, we

Re: TIMEOUT_INITIALIZER() for src/sys/dev.c to avoid timeout_initialized()

2013-12-09 Thread David Gwynne
On 9 Dec 2013, at 6:59 pm, Bret Lambert wrote: > On Mon, Dec 09, 2013 at 01:55:53PM +1000, David Gwynne wrote: >> this is a demonstration of using TIMEOUT_INITIALIZED(). >> >> because we know the timeout is always set up correctly, we dont >> have to test for it all over the place. >> > > [a

Re: TIMEOUT_INITIALIZER() for src/sys/dev.c to avoid timeout_initialized()

2013-12-09 Thread Bret Lambert
On Mon, Dec 09, 2013 at 01:55:53PM +1000, David Gwynne wrote: > this is a demonstration of using TIMEOUT_INITIALIZED(). > > because we know the timeout is always set up correctly, we dont > have to test for it all over the place. > [a bit of snipping...] > - if (timeout_initialized(&rnd_tim

TIMEOUT_INITIALIZER() for src/sys/dev.c to avoid timeout_initialized()

2013-12-08 Thread David Gwynne
= rnd_event_space; struct rand_event *rnd_event_tail = rnd_event_space; -struct timeout rnd_timeout; +struct timeout rnd_timeout = TIMEOUT_INITIALIZER(dequeue_randomness, NULL); struct rndstats rndstats; u_int32_t entropy_pool[POOLWORDS]; u_int entropy_add_ptr; u_char entropy_input_rotate; -void

TIMEOUT_INITIALIZER()

2013-12-08 Thread David Gwynne
-r1.24 timeout.h --- sys/sys/timeout.h 27 Nov 2013 04:28:32 - 1.24 +++ sys/sys/timeout.h 9 Dec 2013 03:51:22 - @@ -64,6 +64,9 @@ struct timeout { int to_flags; /* misc flags */ }; +#define TIMEOUT_INITIALIZER(_f, _a) \ + { { NULL, NULL }, (_f