From 034805e2a66f635ff439997b9e22b3b717e91da2 Mon Sep 17 00:00:00 2001 From: Dave Vasilevsky Date: Sat, 13 Oct 2012 07:32:12 -0400 Subject: [PATCH] Combine linux and BSD endian code --- endian.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/endian.c b/endian.c index ef66652..2490364 100644 --- a/endian.c +++ b/endian.c @@ -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 -#include +#ifdef __linux__ + #include +#else + #include +#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