Skip to content

Commit 53d2ea9

Browse files
committed
Fixed #724.
Fixed type mismatch in msgpack_timestamp. Added 64bit singed postfix.
1 parent b6803a5 commit 53d2ea9

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

include/msgpack/timestamp.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@ static inline bool msgpack_object_to_timestamp(const msgpack_object* obj, msgpac
2828
switch (obj->via.ext.size) {
2929
case 4:
3030
ts->tv_nsec = 0;
31-
_msgpack_load32(uint32_t, obj->via.ext.ptr, &ts->tv_sec);
31+
{
32+
uint32_t v;
33+
_msgpack_load32(uint32_t, obj->via.ext.ptr, &v);
34+
ts->tv_sec = v;
35+
}
3236
return true;
3337
case 8: {
3438
uint64_t value;
3539
_msgpack_load64(uint64_t, obj->via.ext.ptr, &value);
3640
ts->tv_nsec = (uint32_t)(value >> 34);
37-
ts->tv_sec = value & 0x00000003ffffffffL;
41+
ts->tv_sec = value & 0x00000003ffffffffLL;
3842
return true;
3943
}
4044
case 12:

include/msgpack/v1/adaptor/cpp11/chrono.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ struct as<std::chrono::system_clock::time_point> {
4141
uint64_t value;
4242
_msgpack_load64(uint64_t, o.via.ext.data(), &value);
4343
uint32_t nanosec = static_cast<uint32_t>(value >> 34);
44-
uint64_t sec = value & 0x00000003ffffffffL;
44+
uint64_t sec = value & 0x00000003ffffffffLL;
4545
tp += std::chrono::duration_cast<std::chrono::system_clock::duration>(
4646
std::chrono::nanoseconds(nanosec));
4747
tp += std::chrono::seconds(sec);
@@ -79,7 +79,7 @@ struct convert<std::chrono::system_clock::time_point> {
7979
uint64_t value;
8080
_msgpack_load64(uint64_t, o.via.ext.data(), &value);
8181
uint32_t nanosec = static_cast<uint32_t>(value >> 34);
82-
uint64_t sec = value & 0x00000003ffffffffL;
82+
uint64_t sec = value & 0x00000003ffffffffLL;
8383
tp += std::chrono::duration_cast<std::chrono::system_clock::duration>(
8484
std::chrono::nanoseconds(nanosec));
8585
tp += std::chrono::seconds(sec);

0 commit comments

Comments
 (0)