mixing preprocessor directives and C constructs ... ick.

Rob Landley rob at landley.net
Mon Mar 6 09:17:45 PST 2006


On Monday 06 March 2006 9:18 am, Robert P. J. Day wrote:
>   i'm aware that what follows is technically correct but it creeps me
> out just a little.
>
>   in fdisk.c, we see preprocessor directives sneaking into C
> conditional constructs:
>
> 	sgi_other_endian = (BYTE_ORDER == LITTLE_ENDIAN);

Did you follow the whole conversation about dead code elimination?  We _want_ 
this sort of thing.  (Although the current fdisk.c is unlikely to be a good 
example.)

>
> where sgi_other_endian is further incorporated back into the
> definitions of a couple of macros in that same file:
>
> 	#define SGI_SSWAP16(x) (sgi_other_endian ? __swap16(x) \
>
>                                  : (uint16_t)(x))
>
> 	#define SGI_SSWAP32(x) (sgi_other_endian ? __swap32(x) \
>
>                                  : (uint32_t)(x))
>
> i think this whole endianness thing needs rethinking.  or at least a
> good scrubbing.

You are aware that those tests should all be resolved at compile time, right?  
(Done right, anyway.)

The stuff in platform.h should be correct, and everything in busybox should 
use the platform.h stuff.  The current fdisk.c will soon be ripped out by the 
roots and replaced with a fresh from the ground up implementation Garrett's 
working on.  But not this release.

> rday

Rob

-- 
Never bet against the cheap plastic solution.


More information about the busybox mailing list