[ovs-dev] [PATCH v2 2/6] vlog: Simplify module definition.
Russell Bryant
russell at ovn.org
Wed Feb 3 22:04:32 UTC 2016
On 02/03/2016 04:50 PM, Ben Pfaff wrote:
> Until now, vlog had a macro VLOG_DEFINE_THIS_MODULE, which expanded using
> VLOG_DEFINE_MODULE, which expanded using VLOG_DEFINE_MODULE__, and the
> latter macros didn't have any other users. This commit combines them for
> clarity.
>
> Signed-off-by: Ben Pfaff <blp at ovn.org>
Acked-by: Russell Bryant <russell at ovn.org>
A couple of things confused me here so I had to bug you on IRC. :-)
Some comments might be helpful:
> @@ -181,12 +174,23 @@ void vlog_rate_limit(const struct vlog_module *, enum vlog_level,
> * defines a static variable named THIS_MODULE that points to it, for use with
> * the convenience macros below. */
> #define VLOG_DEFINE_THIS_MODULE(MODULE) \
> - VLOG_DEFINE_MODULE(MODULE); \
/* The extern declaration here makes sparse happy. Otherwise it
suggests that VLM_##MODULE should be delcared static. We don't
want to make it static, because this approach will generate a
linker error on duplicate module names */
> + extern struct vlog_module VLM_##MODULE; \
> + struct vlog_module VLM_##MODULE = \
> + { \
> + OVS_LIST_INITIALIZER(&VLM_##MODULE.list), \
> + #MODULE, /* name */ \
> + { VLL_INFO, VLL_INFO, VLL_INFO }, /* levels */ \
> + VLL_INFO, /* min_level */ \
> + true /* honor_rate_limits */ \
> + }; \
> + OVS_CONSTRUCTOR(init_##MODULE) { \
> + vlog_insert_module(&VLM_##MODULE.list); \
> + } \
--
Russell Bryant
More information about the dev
mailing list