Linux 4.13.16
[linux/fpc-iii.git] / include / linux / delayed_call.h
blobf7fa76ae1a9b956a405ee1f1d5bc01acfc83ec2c
1 #ifndef _DELAYED_CALL_H
2 #define _DELAYED_CALL_H
4 /*
5 * Poor man's closures; I wish we could've done them sanely polymorphic,
6 * but...
7 */
9 struct delayed_call {
10 void (*fn)(void *);
11 void *arg;
14 #define DEFINE_DELAYED_CALL(name) struct delayed_call name = {NULL, NULL}
16 /* I really wish we had closures with sane typechecking... */
17 static inline void set_delayed_call(struct delayed_call *call,
18 void (*fn)(void *), void *arg)
20 call->fn = fn;
21 call->arg = arg;
24 static inline void do_delayed_call(struct delayed_call *call)
26 if (call->fn)
27 call->fn(call->arg);
30 static inline void clear_delayed_call(struct delayed_call *call)
32 call->fn = NULL;
34 #endif