[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <200709270900.36602.arnd@arndb.de>
Date: Thu, 27 Sep 2007 09:00:36 +0200
From: Arnd Bergmann <arnd@...db.de>
To: Rob Landley <rob@...dley.net>
Cc: linux-tiny@...enic.com, Tim Bird <tim.bird@...sony.com>,
linux kernel <linux-kernel@...r.kernel.org>,
CE Linux Developers List <celinux-dev@...e.celinuxforum.org>,
Michael Opdenacker <michael@...e-electrons.com>
Subject: Re: [Announce] Linux-tiny project revival
On Thursday 20 September 2007, you wrote:
> So instead of:
> printk(KERN_NOTICE "Fruit=%d\n", banana);
> It would now be:
> printk(KERN_NOTICE, "Fruit=%d\n", banana);
>
> Change the header from:
> #define KERN_NOTICE "<5>"
> to:
> #define KERN_NOTICE 5
>
> Then you can change the printk guts to do something vaguely like (untested):
> #define printk(arg1, arg2, ...) actual_printk("<" #arg1 ">" arg2, __VA_ARGS__)
>
> And so far no behavior has changed. But now the _fun_ part is, you can add a
> config symbol for "what is the minimum loglevel I care about?" Set that as a
> number from 0-9. And then you can define the printk to do:
>
> #define printk(level, str, ...) \
> do { \
> if (level < CONFIG_PRINTK_DOICARE) \
> actual_printk("<" #level ">" str, __VA_ARGS__); \
> } while(0);
>
Assuming that we want to go down that road, I think you can do better with
more evil macro magic, by using something along the lines of
#define KERN_NOTICE "<5>",
#define PRINTK_CONTINUED "",
#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);
Then you don't have to change every single printk in the kernel, but
only those that don't currently come with a log level. More importantly,
you can do the conversion without a flag day, by spreading (an empty)
PRINTK_CONTINUED in places that do need a printk without a log level.
Arnd <><
-
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