Switch to custom byte swapping function.

GCC builtins like __bswap_32 are not portable between versions.
Merge pull request #1977 from kacfengine/bswap

Switch to custom byte swapping function.