lkml.org 
[lkml]   [2007]   [Sep]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [Announce] Linux-tiny project revival
Date
Rob Landley <rob@landley.net> wrote:
| I'm proposing allowing an ignore_loglevel to remove the unused messages at
| compile time so they don't take up space. Doing that requires the levels to
| be integers so they can be compared with < or >, and the remaining changes
| follow logically. (To me, anyway...)

Gcc seems to be smart enough to do contant folding on string
subscripts, so you don't need to change any of the printk()s.
Here is what I mean:

#include <stdio.h>

#define actual_printk printf

#define KERN_ERR "<3>" /* error conditions */
#define KERN_WARNING "<4>" /* warning conditions */
#define KERN_NOTICE "<5>" /* normal but significant condition */
#define printk(str, ...) \
do { \
if ((str)[0] != '<' || (str)[1] < '5') \
actual_printk((str), __VA_ARGS__); \
} while(0);
int main(void)
{
printk(KERN_ERR "error %d\n", 1);
printk(KERN_WARNING "warning %d\n", 2);
printk(KERN_NOTICE "notice %d\n", 3);
printk("no level %d\n", 4);
return 0;
}
--
Dick Streefland //// Altium BV
dick.streefland@altium.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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-09-21 15:31    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site