RFC: size-saving boolean type for busybox
Denis Vlasenko
vda.linux at googlemail.com
Tue Jan 2 14:27:12 PST 2007
On Tuesday 02 January 2007 20:06, Luciano Miguel Ferreira Rocha wrote:
> 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.
I mostly think about places like this one:
./util-linux/fsck_minix.c:static int repair, automatic, verbose, list, show, warn_mode, force;
./util-linux/fsck_minix.c:static int directory, regular, blockdev, chardev, links, symlinks, total;
./util-linux/fsck_minix.c:static int changed; /* flags if the filesystem has been changed */
./util-linux/fsck_minix.c:static int errors_uncorrected; /* flag if some error was not corrected */
./util-linux/fsck_minix.c:static int dirsize = 16;
./util-linux/fsck_minix.c:static int namelen = 14;
./util-linux/fsck_minix.c:static int termios_set;
./util-linux/fsck_minix.c:static int version2;
./util-linux/fsck_minix.c:static int name_depth;
--
vda
More information about the busybox
mailing list