This is the mail archive of the
mailing list for the GCC project.
Re: make sure struct real_value's bitfields are packed
+#define REAL_EXP(REAL) \
+ ((int)((REAL)->uexp ^ (unsigned int)(1 << (EXP_BITS - 1))) \
+ - (1 << (EXP_BITS - 1)))
I hadn't come across this "(x ^ signbit) - signbit" idiom for
implementing sign-extension before. Nice.
Yeah, I found it great as well when I learned about it in the binutils
I don't really like the idiom. It's obfuscated and requires a large
constant, which is costly on some targets. Plain old
(x << EXP_BITS) >> EXP_BITS is much more readable and already gets
recognized by gcc as sign extension.
But it doesn't mean the same thing! To use your idiom, you need
to know the size in bits of int. Messy.