On 04/11/2011 02:19 PM, Josh Stone wrote: > AFAIK, the only roadblock is that our probes are argument-numbered > rather than variadic. I've been thinking for a while that it would be > nice if we had a variadic SDT macro, e.g. STAP_PROBEV, and then UST > could invoke it directly. Since you and I were brainstorming this, > here's a neat trick I found to count __VA_ARGS__: > http://groups.google.com/group/comp.std.c/msg/346fc464319b1ee5 > > I'm going to try to adapt that for SDT, so I'll post if I get it working...
Here's what I came up with: #define _SDT_NARG(...) __SDT_NARG(__VA_ARGS__, 10,9,8,7,6,5,4,3,2,1,0) #define __SDT_NARG(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10, N, ...) N #define _SDT_PROBE_N(provider, name, N, ...) \ _SDT_PROBE(provider, name, N, (__VA_ARGS__)) #define STAP_PROBEV(provider, name, ...) \ _SDT_PROBE_N(provider, name, _SDT_NARG(0,##__VA_ARGS__),##__VA_ARGS__) _SDT_NARG is actually returning the count minus one, and I call it with an extra arg, so we can avoid non-standard empty macro args. Comments? Josh _______________________________________________ ltt-dev mailing list [email protected] http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
