Extend macros to allow flag arguments.

This commit is contained in:
Nick Mathewson 2019-06-20 16:26:05 -04:00
parent 5b252d31ed
commit b6457d4c08
5 changed files with 12 additions and 8 deletions

View File

@ -259,11 +259,11 @@ DUMMY_TYPECHECK_INSTANCE(or_options_t);
* or_options_t.<b>member</b>"
*/
#define VAR(varname,conftype,member,initvalue) \
CONFIG_VAR_ETYPE(or_options_t, varname, conftype, member, initvalue)
CONFIG_VAR_ETYPE(or_options_t, varname, conftype, member, 0, initvalue)
/* As VAR, but uses a type definition in addition to a type enum. */
#define VAR_D(varname,conftype,member,initvalue) \
CONFIG_VAR_DEFN(or_options_t, varname, conftype, member, initvalue)
CONFIG_VAR_DEFN(or_options_t, varname, conftype, member, 0, initvalue)
#define V(member,conftype,initvalue) \
VAR(#member, conftype, member, initvalue)

View File

@ -71,7 +71,7 @@ static config_abbrev_t state_abbrevs_[] = {
DUMMY_TYPECHECK_INSTANCE(or_state_t);
#define VAR(varname,conftype,member,initvalue) \
CONFIG_VAR_ETYPE(or_state_t, varname, conftype, member, initvalue)
CONFIG_VAR_ETYPE(or_state_t, varname, conftype, member, 0, initvalue)
#define V(member,conftype,initvalue) \
VAR(#member, conftype, member, initvalue)

View File

@ -52,7 +52,7 @@ static const char dstate_cur_srv_key[] = "SharedRandCurrentValue";
DUMMY_TYPECHECK_INSTANCE(sr_disk_state_t);
#define VAR(varname,conftype,member,initvalue) \
CONFIG_VAR_ETYPE(sr_disk_state_t, varname, conftype, member, initvalue)
CONFIG_VAR_ETYPE(sr_disk_state_t, varname, conftype, member, 0, initvalue)
#define V(member,conftype,initvalue) \
VAR(#member, conftype, member, initvalue)

View File

@ -30,12 +30,14 @@
* Most modules that use this macro should wrap it in a local macro that
* sets structtype to the local configuration type.
**/
#define CONFIG_VAR_ETYPE(structtype, varname, vartype, membername, initval) \
#define CONFIG_VAR_ETYPE(structtype, varname, vartype, membername, \
varflags, initval) \
{ .member = \
{ .name = varname, \
.type = CONFIG_TYPE_ ## vartype, \
.offset = offsetof(structtype, membername), \
}, \
.flags = varflags, \
.initvalue = initval \
CONF_TEST_MEMBERS(structtype, vartype, membername) \
}
@ -44,13 +46,15 @@
* As CONFIG_VAR_XTYPE, but declares a value using an extension type whose
* type definition is <b>vartype</b>_type_defn.
**/
#define CONFIG_VAR_DEFN(structtype, varname, vartype, membername, initval) \
#define CONFIG_VAR_DEFN(structtype, varname, vartype, membername, \
varflags, initval) \
{ .member = \
{ .name = varname, \
.type = CONFIG_TYPE_EXTENDED, \
.type_def = &vartype ## _type_defn, \
.offset = offsetof(structtype, membername), \
}, \
.flags = varflags, \
.initvalue = initval \
CONF_TEST_MEMBERS(structtype, vartype, membername) \
}

View File

@ -49,7 +49,7 @@ typedef struct test_struct_t {
static test_struct_t test_struct_t_dummy;
#define VAR(varname,conftype,member,initvalue) \
CONFIG_VAR_ETYPE(test_struct_t, varname, conftype, member, initvalue)
CONFIG_VAR_ETYPE(test_struct_t, varname, conftype, member, 0, initvalue)
#define V(member,conftype,initvalue) \
VAR(#member, conftype, member, initvalue)
#define OBSOLETE(varname) \