[PATCH] Optimize manual byte swap implementations using the GCC bswap builtin
Ross Ridge
rridge@csclub.uwaterloo.ca
Sat Nov 29 11:17:00 GMT 2008
Nicholas Miell writes:
>Another somewhat common idiom is:
>
># define swab32(x)\
>((((uint8_t*)&x)[0] << 24) | (((uint8_t*)&x)[1] << 16) | \
> (((uint8_t*)&x)[2] << 8) | (((uint8_t*)&x)[3]))
>
>primarily found in media libraries (a52dec, libdv, libdts, libogmdvd, etc.).
That macro isn't actually a byte swap idiom, it's a big endian read.
It only byte swaps on a little endian machines.
Ross Ridge
More information about the Gcc-patches
mailing list