big endian support

This commit is contained in:
Joe Thornber 2012-03-02 14:05:33 +00:00
parent 784390bb4f
commit 43bd901f16

View File

@ -19,6 +19,7 @@
#ifndef ENDIAN_H
#define ENDIAN_H
#include <endian.h>
#include <stdint.h>
#include <boost/static_assert.hpp>
@ -69,32 +70,32 @@ namespace base {
template <>
inline uint16_t to_cpu<uint16_t, __le16>(__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<uint32_t, __le32>(__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<uint64_t, __le64>(__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));
}
//--------------------------------