Tom Lane <tgl@sss.pgh.pa.us> writes:
[ snip interesting analysis ]
> A nicer approach would be to somehow make use of the datatype of the
> first argument to MemSet. If we could determine at compile time
> that it's supposed to point at a type with at least int alignment,
> then it'd be possible for the compiler to optimize away this check
> in a reasonably safe fashion. I'm not sure if there's a portable
> way to do this, though. There's no "alignof()" construct in C
> :-(. Any ideas?
Well, we could make use of (yet another) GCC-ism: the __alignof__
keyword, which is described here:
http://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Alignment.html#Alignment
I don't like making the code GCC-specific any more than anyone else
does, but given that the code-bloat is specific to the inline version
of newNode (which in the scheme I described earlier would be
GCC-only) -- so introducing a GCC-specific fix for a GCC-specific
problem isn't too bad, IMHO.
Or we could just use your other suggestion: define a variant of
MemSet() and use it when we know it's safe. Not sure which is the
better solution: any comments?
Cheers,
Neil
--
Neil Conway <neilc@samurai.com> || PGP Key ID: DB3C29FC