2
0
mirror of https://github.com/vasi/pixz synced 2024-11-16 21:26:04 +00:00

Combine linux and BSD endian code

This commit is contained in:
Dave Vasilevsky 2012-10-13 07:32:12 -04:00
parent 8c4ae8b0d6
commit 034805e2a6

View File

@ -10,19 +10,21 @@ void xle64enc(uint8_t *d, uint64_t n) {
OSWriteLittleInt64(d, 0, n);
}
#elif defined(__linux__) || defined(__FreeBSD__)
#elif defined(__linux__)
#define _BSD_SOURCE
#include <stdint.h>
#include <asm/byteorder.h>
#ifdef __linux__
#include <endian.h>
#else
#include <sys/endian.h>
#endif
uint64_t xle64dec(const uint8_t *d) {
return __le64_to_cpu(*(uint64_t*)d);
return le64toh(*(uint64_t*)d);
}
void xle64enc(uint8_t *d, uint64_t n) {
*(uint64_t*)d = __cpu_to_le64(n);
*(uint64_t*)d = htole64(n);
}
#else