RFC: size-saving boolean type for busybox
David Daney
ddaney at avtrex.com
Tue Jan 2 09:40:24 PST 2007
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.
>
> 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.
>
> How about this?
>
> #if defined(i386) /* || defined(...) as needed */
> typedef unsigned char bbool;
> #else
> typedef unsigned bbool;
> #endif
>
Did you do a size comparison?
How about adding a check for C99 and if true, just use _Bool?
Also MIPS can efficiently access bytes, so you could add mips to the test.
Thanks,
David Daney
More information about the busybox
mailing list