This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: roland/systemtap branch
On 05/24/2012 03:18 PM, Carlos O'Donell wrote:
> Two thumbs up from me.
I also think this sort of patch has a high reward-to-risk ratio
and would like to see something like it go in.
Re this:
# define LIBC_PROBE(name, n, ...) DUMMY_PROBE##n (__VA_ARGS__)
...
/* This silliness lets us evaluate all the arguments for each arity
of probe. My kingdom for a real macro system. */
# define DUMMY_PROBE0() do {} while (0)
# define DUMMY_PROBE1(a1) do {} while ((void) (a1), 0)
# define DUMMY_PROBE2(a1, a2) do {} while ((void) (a1), \
(void) (a2), 0)
# define DUMMY_PROBE3(a1, a2, a3) do {} while ((void) (a1), \
(void) (a2), \
(void) (a3), 0)
... and so on for DUMMY_PROBE4 etc. ...
How about something like the following instead? It's still silly, but
arguably it's less silly, and it's indubitably shorter.
#define LIBC_PROBE(name, n, ...) \
do { \
_Bool probe_args[] = { 0, ## __VA_ARGS__ }; \
_Bool verify_arg_count[sizeof probe_args == n + 1 ? 1 : -1]; \
(void) verify_arg_count; \
} while (0)
I tried to rewrite it to avoid the need for 'n' entirely. I can do this
for the dummy case, but not for the USE_STAP_PROBE case as the <sys/sdt.h>
stuff insists on a literal decimal constant for 'n'; so I stopped with the
above.