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)); } //--------------------------------