Thomas Rast <tr@xxxxxxxxxxxxx> writes: > Here's a version that has a fat comment instead of the removal. > > Also, since I was rerolling anyway I put a reason why we need this. > In the original motivation I actually created more functions > afterwards, which made it more convincing, but the problem already > exists. Thanks. I considered the bottom one the real declaration (with the top one a forward declaration we need to make the result compile), by the way, so there may be no redundancy anywhere ;-) > commit-slab.h | 24 ++++++++++++++++++------ > 1 file changed, 18 insertions(+), 6 deletions(-) > > diff --git a/commit-slab.h b/commit-slab.h > index d77aaea..21d54f1 100644 > --- a/commit-slab.h > +++ b/commit-slab.h > @@ -45,8 +45,8 @@ struct slabname { \ > }; \ > static int stat_ ##slabname## realloc; \ > \ > -static void init_ ##slabname## _with_stride(struct slabname *s, \ > - unsigned stride) \ > +static inline void init_ ##slabname## _with_stride(struct slabname *s, \ > + unsigned stride) \ > { \ > unsigned int elem_size; \ > if (!stride) \ > @@ -58,12 +58,12 @@ struct slabname { \ > s->slab = NULL; \ > } \ > \ > -static void init_ ##slabname(struct slabname *s) \ > +static inline void init_ ##slabname(struct slabname *s) \ > { \ > init_ ##slabname## _with_stride(s, 1); \ > } \ > \ > -static void clear_ ##slabname(struct slabname *s) \ > +static inline void clear_ ##slabname(struct slabname *s) \ > { \ > int i; \ > for (i = 0; i < s->slab_count; i++) \ > @@ -73,8 +73,8 @@ struct slabname { \ > s->slab = NULL; \ > } \ > \ > -static elemtype *slabname## _at(struct slabname *s, \ > - const struct commit *c) \ > +static inline elemtype *slabname## _at(struct slabname *s, \ > + const struct commit *c) \ > { \ > int nth_slab, nth_slot; \ > \ > @@ -98,4 +98,16 @@ struct slabname { \ > \ > static int stat_ ##slabname## realloc > > +/* > + * Note that this seemingly redundant second declaration is required > + * to allow a terminating semicolon, which makes instantiations look > + * like function declarations. I.e., the expansion of > + * > + * define_commit_slab(indegree, int); > + * > + * ends in 'static int stat_indegreerealloc;'. This would otherwise > + * be a syntax error according (at least) to ISO C. It's hard to > + * catch because GCC silently parses it by default. > + */ > + > #endif /* COMMIT_SLAB_H */ -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html