From mboxrd@z Thu Jan 1 00:00:00 1970 From: jistone@redhat.com (Josh Stone) Date: Mon, 11 Apr 2011 15:29:41 -0700 Subject: [ltt-dev] SystemTAP support in tracepoints In-Reply-To: <4DA3704C.8010502@redhat.com> References: <20110410174444.GA30466@Krystal> <4DA3704C.8010502@redhat.com> Message-ID: <4DA380D5.80608@redhat.com> 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