Re: [RFC] New kernel-message logging API (take 2)

From: Kyle Moffett
Date: Fri Sep 28 2007 - 03:44:40 EST

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;

Kyle Moffett

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at