diff options
| author | 2012-11-20 05:20:11 +0100 | |
|---|---|---|
| committer | 2012-11-20 05:20:11 +0100 | |
| commit | 4b7a4ff8e5098912ce95fb4ef7264e9fb71c819f (patch) | |
| tree | 49604061afb10dff15b05bdd3771574a990bc563 | |
| parent | 8173b48515dd830da350eb98f73dde210c5d1be4 (diff) | |
| download | libimobiledevice-4b7a4ff8e5098912ce95fb4ef7264e9fb71c819f.tar.gz libimobiledevice-4b7a4ff8e5098912ce95fb4ef7264e9fb71c819f.tar.bz2 | |
endianness: define htole32/le32toh for systems lacking it
| -rw-r--r-- | include/endianness.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/endianness.h b/include/endianness.h index 1f99fa7..9dfcd0c 100644 --- a/include/endianness.h +++ b/include/endianness.h | |||
| @@ -46,6 +46,18 @@ | |||
| 46 | #define htobe32 be32toh | 46 | #define htobe32 be32toh |
| 47 | #endif | 47 | #endif |
| 48 | 48 | ||
| 49 | #ifndef le32toh | ||
| 50 | #if __BYTE_ORDER == __BIG_ENDIAN | ||
| 51 | #define le32toh(x) __bswap_32(x) | ||
| 52 | #else | ||
| 53 | #define le32toh(x) (x) | ||
| 54 | #endif | ||
| 55 | #endif | ||
| 56 | |||
| 57 | #ifndef htole32 | ||
| 58 | #define htole32 le32toh | ||
| 59 | #endif | ||
| 60 | |||
| 49 | #ifndef __bswap_64 | 61 | #ifndef __bswap_64 |
| 50 | #define __bswap_64(x) ((((x) & 0xFF00000000000000ull) >> 56) \ | 62 | #define __bswap_64(x) ((((x) & 0xFF00000000000000ull) >> 56) \ |
| 51 | | (((x) & 0x00FF000000000000ull) >> 40) \ | 63 | | (((x) & 0x00FF000000000000ull) >> 40) \ |
