[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9b4.46fd1153.78517@altium.nl>
Date: Fri, 28 Sep 2007 14:36:03 -0000
From: dick.streefland@...ium.nl (Dick Streefland)
To: linux-kernel@...r.kernel.org
Subject: Re: [Announce] Linux-tiny project revival
Rob Landley <rob@...dley.net> wrote:
| The "change every printk in the kernel" suggestion came from me trying to
| figure out how to get the printk() calls below a certain log level to
| optimize out and not take up space in the binary.
|
| The above doesn't address the original cause of the thread, as far as I can
| tell.
It does, provided you change the macro definition to:
#define _printk(level, str, ...) \
do { \
if (sizeof(level) == 1) /* continued printk */\
actual_printk(str, __VA_ARGS__); \
else if ((level[1] - '0') < CONFIG_PRINTK_DOICARE) \
actual_printk(level str, __VA_ARGS__); \
} while(0);
#define printk(level_str, ...) _printk(level_str, __VA_ARGS__)
Gcc will do constant folding on the string subscripts, and remove the
code and the string constants for calls above the desired level.
This is basically the same as I proposed in my earlier message [*],
but with the disadvantage that you need to modify all printk() calls
without an explicit level and add the ugly comma to the KERN_* macros.
Just compile the code in my message with -O and -S and you will see
that the KERN_NOTICE call and the corresponding string literal are
optimized away.
[*] http://lkml.org/lkml/2007/9/21/151
--
Dick Streefland //// Altium BV
dick.streefland@...ium.nl (@ @) http://www.altium.com
--------------------------------oOO--(_)--OOo---------------------------
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists