Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 04 Nov 2008 10:28:11 +0100
From:      Christoph Mallon <christoph.mallon@gmx.de>
To:        Joerg Sonnenberger <joerg@britannica.bec.de>
Cc:        svn-src-all@freebsd.org
Subject:   Re: svn commit: r184605 - head/sys/dev/usb
Message-ID:  <491015AB.7070508@gmx.de>
In-Reply-To: <20081103225453.GA1509@britannica.bec.de>
References:  <200811032209.mA3M9RhK077380@svn.freebsd.org>	<490F800E.9080201@gmx.de> <20081103225453.GA1509@britannica.bec.de>

next in thread | previous in thread | raw e-mail | index | archive | help
Joerg Sonnenberger wrote:
> On Mon, Nov 03, 2008 at 11:49:50PM +0100, Christoph Mallon wrote:
>> You may want to make cmd[] static and/or const, so the compiler really  
>> just puts the bytes in the data section instead of generating code,  
>> which pretty much is the same as the assignments you just removed.
> 
> I didn't make it const originally as I am not sure if the USB stack will
> never modify the buffer.

GCC generates 31 movb instructions to initialise the array on entry of 
the function. Every movb is 5 Bytes long (opcode + mod r/m + sib + 
offset + immediate). 31 * 5 = 155 Bytes. It is only sensible to use 
static initialisation for a local array, which contains lots of zeroes, 
if it can be made static or const (GCC is clever enough to turn a const 
array into a static one). Yes, GCC could be more clever and use movl 
instead of movb, but it isn't.

	Christoph



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?491015AB.7070508>