From owner-freebsd-current Thu Jan 28 17:30:01 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id RAA24627 for freebsd-current-outgoing; Thu, 28 Jan 1999 17:30:01 -0800 (PST) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from apollo.backplane.com (apollo.backplane.com [209.157.86.2]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id RAA24575 for ; Thu, 28 Jan 1999 17:29:59 -0800 (PST) (envelope-from dillon@apollo.backplane.com) Received: (from dillon@localhost) by apollo.backplane.com (8.9.2/8.9.1) id RAA16381; Thu, 28 Jan 1999 17:29:57 -0800 (PST) (envelope-from dillon) Date: Thu, 28 Jan 1999 17:29:57 -0800 (PST) From: Matthew Dillon Message-Id: <199901290129.RAA16381@apollo.backplane.com> To: Steve Kargl Cc: peter.jeremy@auss2.alcatel.com.au, current@FreeBSD.ORG Subject: Re: indent(1) and style(9) (was: btokup() macro in sys/malloc.h) References: <199901290122.RAA27878@troutmask.apl.washington.edu> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG :> :> More then judicious use -- inlines are an incredible advantage. Most :> people don't realize that GCC will optimize constant arguments through :> an inline call. Try this: :> :> static __inline Yah, and if it's static it will not even output code for fubar. I've never trusted -O3, though, and you can't put static procedures in header files ( because then you can't fall back to -O2 ). Thus, for this sort of optimization to work the procedure must be in the same source file, which kills the modularity. Also, on top of all of that, GCC may not make a good decision on whether to actually inline the static or whether to call it - it might wind up inlining a large routine that you call many times in your module and both bloat the code and destroy the L1 cache. I think it's better to make things explicitly __inline and to put them in the proper subsystem's header files. It isn't worth depending on -O3 for things to compile: -O3 Optimize yet more. This turns on everything -O2 does, along with also turning on -finline-func- tions. -Matt :Matt, : :int :fubar(int c) :{ : if (c & 1) : ++c; : if (c & 2) : ++c; : return(c); :} : :void :fubar2(void) :{ : volatile int x; : : x = fubar(0); : x = fubar(1); : x = fubar(2); : x = fubar(3); :} : :% cc -S -O3 x.c :% cat x.s : :fubar2: : pushl %ebp : movl %esp,%ebp : subl $4,%esp : xorl %eax,%eax <----- fubar (0) : movl %eax,-4(%ebp) : movl $3,-4(%ebp) <----- fubar (1) : movl $3,-4(%ebp) <----- fubar (2) : movl $4,-4(%ebp) <----- fubar (3) : leave : ret : :-- :Steve : :finger kargl@troutmask.apl.washington.edu :http://troutmask.apl.washington.edu/~clesceri/kargl.html : Matthew Dillon To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message