insmod broken in 1.1.1
Rob Landley
rob at landley.net
Sun Mar 26 21:15:06 UTC 2006
On Sunday 26 March 2006 10:20 am, Robert P. J. Day wrote:
> > And _this_ is why you want to use if(ENABLE_BLAH) instead of #if
> > ENABLE_BLAH, so the compiler barfs if you get the symbol wrong
> > rather than silently ignoring it. (And no, "#ifdef UNKNOWN_SYMBOL"
> > never caught this sort of thing either.)
>
> looking at this a bit closer, would it not be possible to move all
> endian-ness checking into include/platform.h and get that sort of
> thing out of the source files themselves? you know -- like how it's
> done in the header file <netinet/in.h>:
>
> # if __BYTE_ORDER == __BIG_ENDIAN
> # define ntohl(x) (x)
> # define ntohs(x) (x)
> # define htonl(x) (x)
> # define htons(x) (x)
> # else
> # if __BYTE_ORDER == __LITTLE_ENDIAN
> # define ntohl(x) __bswap_32 (x)
> # define ntohs(x) __bswap_16 (x)
> # define htonl(x) __bswap_32 (x)
> # define htons(x) __bswap_16 (x)
> # endif
> # endif
>
> and implement the source files in terms of *these* primitives. i
> mean, does libbb/md5.c really need to define its own "swap" routines
> based on endianness?
I was actually pondering trying to use the networking macros in place of
endianness tests, but unfortunately the networking macros only go one way:
they provide HOST2BIGEND(x) and BIGEND2HOST(x). We'd need HOST2LITEND(x) and
LITEND2HOST(x) as well to do it right.
But yeah, there's room for cleanup here...
Rob
--
Never bet against the cheap plastic solution.
More information about the busybox
mailing list