From 73a5f983dbfbe47e2338871063f26f00adfce85c Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Tue, 11 Dec 2018 14:17:06 -0800 Subject: thunk: fixup handling arity=0 thunks Overlooked this, but it's also odd how the __VA_ARGS__ when empty is still being passed as a separate argument requiring the addition of the _nil placeholders. --- thunk.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/thunk.h b/thunk.h index 2957f22..1ae6463 100644 --- a/thunk.h +++ b/thunk.h @@ -36,7 +36,7 @@ struct thunk_t { /* Macros for declaring the thunk environment struct members, we need a variant * for each supported arity. */ -#define _THUNK_GEN_STRUCT_0() +#define _THUNK_GEN_STRUCT_0(_nil) #define _THUNK_GEN_STRUCT_2(_t_a, _n_a) \ _t_a _n_a; @@ -125,7 +125,7 @@ struct thunk_t { /* Macros for populating the thunk environment struct members when instantiating the * thunk, we need a variant for each supported arity. */ -#define _THUNK_GEN_INSTANTIATE_0(_env) +#define _THUNK_GEN_INSTANTIATE_0(_env, _nil) #define _THUNK_GEN_INSTANTIATE_2(_env, _t_a, _n_a) \ _env->_n_a = _n_a; @@ -214,7 +214,8 @@ struct thunk_t { /* Macros for dispatching the embedded thunk from its associated environment, * we need a variant for each supported arity. */ -#define _THUNK_GEN_DISPATCH_0(_name, _env) +#define _THUNK_GEN_DISPATCH_0(_name, _env, _nil) \ + _name() #define _THUNK_GEN_DISPATCH_2(_name, _env, _t_a, _n_a) \ _name(_env->_n_a) @@ -258,7 +259,8 @@ struct thunk_t { /* Macros for prototyping the function being thunked, * we need a variant for each supported arity. */ -#define _THUNK_GEN_PROTO_0(_name) +#define _THUNK_GEN_PROTO_0(_name, _nil) \ + _name(void) #define _THUNK_GEN_PROTO_2(_name, _t_a, _n_a) \ _name(_t_a _n_a) -- cgit v1.2.3