![]() | |||||||||||||
Messages in this thread |
On Sep 28, 2007, at 03:31:11, Geert Uytterhoeven wrote:
> Can't you store the loglevel in the kprint_block and check it in
> all successive kprint_*() macros? If gcc knows it's constant, it
> can optimize the non-wanted code away. As other fields in struct
> kprint_block cannot be constant (they store internal state), you
> have to split it like:
>
> struct kprint_block {
> int loglevel;
> struct real_kprint_block real; /* internal state */
> }
>
> and pass &block.real() instead of &block to all successive internal
> functions. I haven't tried this, so let's hope gcc is actually
> smart enough...
Well actually, I believe you could just do:
struct kprint_block {
const int loglevel;
[...];
};
Then cast away the constness to actually set it initially:
*((int *)&block.loglevel) = LOGLEVEL;
Cheers,
Kyle Moffett
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
| ||||||||||||
| Last update: 2007-09-28 09:47 [from the cache] ©2003-2008 | |||||||||||||