Vadim Lobanov <[email protected]> wrote:
>
> On Tue, 20 Sep 2005, Andrey Panin wrote:
>
> > On 263, 09 20, 2005 at 02:14:55PM +0800, colin wrote:
> > >
> > > Hi there,
> > > I tried to make kernel with CONFIG_PRINTK off. I considered it should become
> > > smaller, but it didn't because it actually isn't an empty function, and
> > > there are many copies of it in vmlinux, not just one. Here is its
> > > definition:
> > > static inline int printk(const char *s, ...) { return 0; }
> > >
> > > I change the definition to this and it can greatly reduce the size by about
> > > 5%:
> > > #define printk(...) do {} while (0)
> > > However, this definition would lead to error in some situations. For
> > > example:
> > > 1. (printk)
> > > 2. ret = printk
> > >
> > > I hope someone could suggest a better definition of printk that can both
> > > make printk smaller and eliminate errors.
> >
> > What about the macro below ?
> >
> > #define printk(...) ({ do { } while(0); 0; })
>
> So what does the do-while loop give us in the above case? In other
> words, why not just do the following...?
>
> #define printk(...) ({ 0; })
>
You may find that when printk() is a static inline there are still copies
of the control string in the generated kernel image:
printk("foo %d\n", bar());
must still evaluate bar() and may cause "foo %d\n" to turn up in vmlinux.
IIRC later versions of gcc do remove the unreferenced string.
If printk is a macro, it all of course disappears.
-
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]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
|
|