Fixed type mismatch in msgpack_timestamp.
Added 64bit singed postfix.
This commit is contained in:
Takatoshi Kondo
2018-08-26 10:58:47 +09:00
parent b6803a5fec
commit 53d2ea9ad3
2 changed files with 8 additions and 4 deletions

View File

@@ -28,13 +28,17 @@ static inline bool msgpack_object_to_timestamp(const msgpack_object* obj, msgpac
switch (obj->via.ext.size) {
case 4:
ts->tv_nsec = 0;
_msgpack_load32(uint32_t, obj->via.ext.ptr, &ts->tv_sec);
{
uint32_t v;
_msgpack_load32(uint32_t, obj->via.ext.ptr, &v);
ts->tv_sec = v;
}
return true;
case 8: {
uint64_t value;
_msgpack_load64(uint64_t, obj->via.ext.ptr, &value);
ts->tv_nsec = (uint32_t)(value >> 34);
ts->tv_sec = value & 0x00000003ffffffffL;
ts->tv_sec = value & 0x00000003ffffffffLL;
return true;
}
case 12:

View File

@@ -41,7 +41,7 @@ struct as<std::chrono::system_clock::time_point> {
uint64_t value;
_msgpack_load64(uint64_t, o.via.ext.data(), &value);
uint32_t nanosec = static_cast<uint32_t>(value >> 34);
uint64_t sec = value & 0x00000003ffffffffL;
uint64_t sec = value & 0x00000003ffffffffLL;
tp += std::chrono::duration_cast<std::chrono::system_clock::duration>(
std::chrono::nanoseconds(nanosec));
tp += std::chrono::seconds(sec);
@@ -79,7 +79,7 @@ struct convert<std::chrono::system_clock::time_point> {
uint64_t value;
_msgpack_load64(uint64_t, o.via.ext.data(), &value);
uint32_t nanosec = static_cast<uint32_t>(value >> 34);
uint64_t sec = value & 0x00000003ffffffffL;
uint64_t sec = value & 0x00000003ffffffffLL;
tp += std::chrono::duration_cast<std::chrono::system_clock::duration>(
std::chrono::nanoseconds(nanosec));
tp += std::chrono::seconds(sec);