Little-endian PowerPC
Little-endian PowerPC
Posted Oct 8, 2010 15:29 UTC (Fri) by jengelh (subscriber, #33263)In reply to: Little-endian PowerPC by etienne
Parent article: Little-endian PowerPC
>but I did not find a way to make GCC use it (i.e. either inline the bswap() or recognise the three shift sequence) on a i386 host...
Works here. Optimizer starts recognizing int s = ((((argc) & 0xff000000) >> 24) | (((argc) & 0x00ff0000) >> 8) | (((argc) & 0x0000ff00) << 8) | (((argc) & 0x000000ff) << 24)); on -O2 and issues a bswap for it.
Alternatively, you could use the same trick as glibc's htonl: int s = __bswap_32(argc). Or even directly __builtin_bswap32 as documented in gcc.info.
