1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
/* contrived usage example */
#include <stdio.h>
#include <stdlib.h>
#include "thunk.h"
THUNK_DEFINE_STATIC(sum, int, a, int, b, int *, res)
{
*res = a + b;
return 0;
}
THUNK_DEFINE_STATIC(mult, int, a, int, b, int, c, int *, res)
{
*res = a * b * c;
return 0;
}
int normalized_helper(thunk_t *thunk)
{
return thunk_dispatch(thunk);
}
int main(void)
{
int out;
normalized_helper(THUNK(sum(1, 2, &out)));
printf("out: %i\n", out);
normalized_helper(THUNK(mult(9, 7, 100, &out)));
printf("out: %i\n", out);
return EXIT_SUCCESS;
}
|