Re: [Announce] Linux-tiny project revival

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rob Landley <[email protected]> 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
[email protected]           (@ @)          http://www.altium.com
--------------------------------oOO--(_)--OOo---------------------------

-
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/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux