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 [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to