From 43bd901f162cb306fba5fda2853173acbf68f371 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Fri, 2 Mar 2012 14:05:33 +0000 Subject: [PATCH] big endian support --- endian_utils.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/endian_utils.h b/endian_utils.h index 5ddb1e5..50a65e2 100644 --- a/endian_utils.h +++ b/endian_utils.h @@ -19,6 +19,7 @@ #ifndef ENDIAN_H #define ENDIAN_H +#include #include #include @@ -69,32 +70,32 @@ namespace base { template <> inline uint16_t to_cpu(__le16 const &d) { - return d.v_; + return le16toh(d.v_); } template <> inline __le16 to_disk<__le16, uint16_t>(uint16_t const &v) { - return __le16(v); + return __le16(htole16(v)); } template <> inline uint32_t to_cpu(__le32 const &d) { - return d.v_; + return le32toh(d.v_); } template <> inline __le32 to_disk<__le32, uint32_t>(uint32_t const &v) { - return __le32(v); + return __le32(htole32(v)); } template <> inline uint64_t to_cpu(__le64 const &d) { - return d.v_; + return le64toh(d.v_); } template <> inline __le64 to_disk<__le64, uint64_t>(uint64_t const &v) { - return __le64(v); + return __le64(htole64(v)); } //--------------------------------