This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [libvirt] [PATCH] build: work around older systemtap header


On 07/05/2011 10:03 AM, Eric Blake wrote:
> It is really annoying that gcc does not provide any counterpart to
> __typeof__ that would let you produce the decayed type of an input
> argument - life would be much simpler if there were a way to decay an
> expression of type 'char[100]' into an intermediate variable of type
> 'char *'.
> 
> At any rate, since none of our current uses of PROBE() pass either 'long
> long' or a function call that returns 'char *', we aren't adding any
> additional problems by accepting this patch, but we also might be adding
> a latent bug that would be hard to diagnose in the future.  I'm not sure
> whether we want to apply this patch, or just require systemtap 1.3 or
> newer as a prerequisite for compiling libvirt.  Thoughts?  How prevalent
> are systemtap 1.2 installations?

Hi - I'm a systemtap developer, and happened upon this thread in a
google search.  I'm CCing the systemtap list in this reply, so if any of
those readers want a fuller context, start around here:
https://www.redhat.com/archives/libvir-list/2011-July/msg00053.html

I'm sorry to discover that you're fighting old sdt.h bugs.  If only we
could put on our time-traveling cap and get it right the first time...
We do hope that all the corner cases are dealt with correctly in the
newest systemtap package.  Please let us know if you find otherwise.

All these typing issues are indeed very hairy to get right, which is a
large part of what inspired our sdt.h rewrite in 1.4.  If you really
want to maintain compatibility with older sdt.h, then perhaps the newer
version can guide you in wrapping around some of the issues.  For
example, dealing with array types, the new version has:

#define _SDT_ARGARRAY(x)	(__builtin_classify_type (x) == 14 \
				 || __builtin_classify_type (x) == 5)

So perhaps you could copy that macro and let your compatibility casting
do something like this:

#define _SDT_CAST(x) \
    __builtin_choose_expr (_SDT_ARGARRAY(x), (uintptr_t)(x), (x))

That way array-like types will be cast, but all others will be left with
their proper size and signedness, including e.g. any long long that
wouldn't fit in a 32-bit intptr.  That __builtin_choose_expr only works
in C, but hopefully for libvirt that should suffice.

HTH,
Josh Stone


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]