diff options
author | Adam Borowski <kilobyte@angband.pl> | 2010-08-20 02:12:53 +0200 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2010-08-20 02:12:53 +0200 |
commit | b25ec0a923318fd601619cd0bd89a9c262ef74e1 (patch) | |
tree | 38d077a4e21a31ffa6ea0da77978e4e4ccd4adb1 /crawl-ref/source/endianness.h | |
parent | a290ba3a83431e38b1d54ed611e7892e38e0fdfd (diff) | |
download | crawl-ref-b25ec0a923318fd601619cd0bd89a9c262ef74e1.tar.gz crawl-ref-b25ec0a923318fd601619cd0bd89a9c262ef74e1.zip |
The transactional save packager.
Diffstat (limited to 'crawl-ref/source/endianness.h')
-rw-r--r-- | crawl-ref/source/endianness.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/crawl-ref/source/endianness.h b/crawl-ref/source/endianness.h new file mode 100644 index 0000000000..d9e96b1940 --- /dev/null +++ b/crawl-ref/source/endianness.h @@ -0,0 +1,36 @@ +#include <sys/types.h> +#include <sys/param.h> + +#ifndef htole32 + #if BYTE_ORDER == LITTLE_ENDIAN + #define htole32(x) (x) + #else + #if BYTE_ORDER == BIG_ENDIAN + #define htole32(x) \ + ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ + (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) + #else + #error No endianness given. + #endif + #endif +#endif + +#ifndef htole64 + #if BYTE_ORDER == LITTLE_ENDIAN + #define htole64(x) (x) + #else + #if BYTE_ORDER == BIG_ENDIAN + #define htole64(x) \ + ( (((x) & 0xff00000000000000ull) >> 56) \ + | (((x) & 0x00ff000000000000ull) >> 40) \ + | (((x) & 0x0000ff0000000000ull) >> 24) \ + | (((x) & 0x000000ff00000000ull) >> 8) \ + | (((x) & 0x00000000ff000000ull) << 8) \ + | (((x) & 0x0000000000ff0000ull) << 24) \ + | (((x) & 0x000000000000ff00ull) << 40) \ + | (((x) & 0x00000000000000ffull) << 56)) + #else + #error No endianness given. + #endif + #endif +#endif |