[lkml]   [2007]   [Sep]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [Announce] Linux-tiny project revival
Rob Landley <> 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.


Dick Streefland //// Altium BV (@ @)
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2007-09-28 16:39    [from the cache]
©2003-2014 Jasper Spaans. hosted at Digital Ocean