From owner-cvs-src@FreeBSD.ORG Sun Sep 28 21:32:41 2008 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E3E42106568D for ; Sun, 28 Sep 2008 21:32:41 +0000 (UTC) (envelope-from christoph.mallon@gmx.de) Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by mx1.freebsd.org (Postfix) with SMTP id 473C48FC1C for ; Sun, 28 Sep 2008 21:32:40 +0000 (UTC) (envelope-from christoph.mallon@gmx.de) Received: (qmail invoked by alias); 28 Sep 2008 21:05:57 -0000 Received: from p54A3E885.dip.t-dialin.net (EHLO tron.homeunix.org) [84.163.232.133] by mail.gmx.net (mp008) with SMTP; 28 Sep 2008 23:05:57 +0200 X-Authenticated: #1673122 X-Provags-ID: V01U2FsdGVkX187nNYf2Pg7KOq7JOiFlYBmarha2turfYFpWovQx+ 0CU6vpRzFYg5Q9 Message-ID: <48DFF1AE.6060408@gmx.de> Date: Sun, 28 Sep 2008 23:05:50 +0200 From: Christoph Mallon User-Agent: Thunderbird 2.0.0.17 (X11/20080927) MIME-Version: 1.0 To: Kostik Belousov References: <200809270009.m8R09OTF000738@repoman.freebsd.org> <20080927084606.GZ47828@deviant.kiev.zoral.com.ua> <48DFE13E.2030200@delphij.net> <20080928203210.GA2433@deviant.kiev.zoral.com.ua> In-Reply-To: <20080928203210.GA2433@deviant.kiev.zoral.com.ua> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-FuHaFi: 0.53 Cc: Xin LI , cvs-src@freebsd.org, src-committers@freebsd.org, d@delphij.net, cvs-all@freebsd.org Subject: Re: cvs commit: src/sbin/init init.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Sep 2008 21:32:42 -0000 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