Michael Matz
23.02.10 14:17 >>> On Tue, 23 Feb 2010, Jan Beulich wrote: Richard Guenther
23.02.10 12:05 >>> The above contains an obfustcated offsetof. Using offsetof (or __builtin_offsetof if the kernel doesn't have a suitable definition of offsetof somewhere) should work fine. The header where this gets defined represents an interface between Xen host and guests. It is intentionally written in a way that does not make any assumptions on the environment within which it would be compiled - hence no offsetof() and no gcc extensions.
Relying on "(long)s->ring - (long)s" being a constant expression _is_ a GCC extension. You have to use offsetof:
While this may be an extension, it's one that all compilers I have access to support, and thus is usable in common code. If 's' were a variable, I would tend to agree that it's not portable. But with 's' being (and equivalent of) NULL, I certainly don't, and would expect the compiler to need fixing (I would bet Xen is not the only piece of software in the world using code like this). Nevertheless I'll also check with the Xen community on whether some sort of sufficiently portable fix can be implemented there.
#define __RING_SIZE(_s, _sz) \ (__RD32(((_sz) - offsetof(struct netif_rx_sring, ring)) / sizeof((_s)->ring[0])))
Again - this is not an option. This header, for example, also needs to be usable on Windows, and as far as I recall Windows (the more its DDK) doesn't use or provide standard types and macros (i.e. they may have an OFFSETOF() macro instead). Jan -- To unsubscribe, e-mail: opensuse-kernel+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kernel+help@opensuse.org