RFC: size-saving boolean type for busybox

Luciano Miguel Ferreira Rocha strange at nsk.no-ip.org
Tue Jan 2 11:06:24 PST 2007


On Tue, Jan 02, 2007 at 05:57:58PM +0100, Denis Vlasenko wrote:
> Hi people,
> 
> I am thinking about introducing a boolean type for busybox.
> In C people usually use int, but it takes 4 bytes of data
> or bss when you have global flag variable.
> 
> C99 has _Bool and on i386 it really takes 1 byte,
> at least with gcc 4.1.1 -Os, but I am hot sure about
> other versions and especially other arches.

What about subsequent declarations? Do they immediatly follow the byte?
If not, then there's really no space saved.

> OTOH, there are CPUs which _really_ have hard time
> dealing with 1-byte integers (generated code is much bigger),
> so using uint8_t as "standard" type for a flag variable isn't ok.

And access is more costly, too. And if the data does get packed, then
access to the following variables will be costly too, until the moment
other bools realign them at 4 bytes.

However, I'm not against defining and using a bool type. Then these
things can be tested.

-- 
lfr
0/0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://busybox.net/lists/busybox/attachments/20070102/b399edb9/attachment.pgp 


More information about the busybox mailing list