Date: Sun, 28 Sep 2008 23:05:50 +0200 From: Christoph Mallon <christoph.mallon@gmx.de> To: Kostik Belousov <kostikbel@gmail.com> Cc: Xin LI <delphij@freebsd.org>, cvs-src@freebsd.org, src-committers@freebsd.org, d@delphij.net, cvs-all@freebsd.org Subject: Re: cvs commit: src/sbin/init init.c Message-ID: <48DFF1AE.6060408@gmx.de> In-Reply-To: <20080928203210.GA2433@deviant.kiev.zoral.com.ua> References: <200809270009.m8R09OTF000738@repoman.freebsd.org> <20080927084606.GZ47828@deviant.kiev.zoral.com.ua> <48DFE13E.2030200@delphij.net> <20080928203210.GA2433@deviant.kiev.zoral.com.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
Kostik Belousov wrote: > On Sun, Sep 28, 2008 at 12:55:42PM -0700, Xin LI wrote: >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> Kostik Belousov wrote: >>> On Sat, Sep 27, 2008 at 12:09:10AM +0000, Xin LI wrote: >>>> delphij 2008-09-27 00:09:10 UTC >>>> >>>> FreeBSD src repository >>>> >>>> Modified files: >>>> sbin/init init.c >>>> Log: >>>> SVN rev 183391 on 2008-09-27 00:09:10Z by delphij >>>> >>>> Static-ify procedures in init(8). >>>> >>>> Revision Changes Path >>>> 1.66 +79 -79 src/sbin/init/init.c >>> What is a reason for the change ? >> This would reduce the size of generated binary... > > I am quite curious. Could you, please, show the numbers. > Is the reduction in size is due to function inlining, or it is purely > symbol table size issue ? If a function or variable can be made static, it should be. There is basically not excuse not to do so. In fact, it is considered a design flaw of C, that symbols default to external linkage instead of internal by default. The compiler can do more optimisations on things, it knows it is the only user of. For example it can change the calling convention of functions to pass parameters in registers instead of on the stack, if it knows all callers. If a function is not static, it must assume there are callers, which it has not control of. Changing the calling convention is just one example of possible optimisations. Further it reduces the chances of name clashes with functions local to other translation units. Regards Christoph
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?48DFF1AE.6060408>