2 * MessagePack for C TimeStamp
4 * Copyright (C) 2018 KONDO Takatoshi
6 * Distributed under the Boost Software License, Version 1.0.
7 * (See accompanying file LICENSE_1_0.txt or copy at
8 * http://www.boost.org/LICENSE_1_0.txt)
10 #ifndef MSGPACK_TIMESTAMP_H
11 #define MSGPACK_TIMESTAMP_H
13 #include <vendor/msgpack/object.h>
20 typedef struct msgpack_timestamp
{
25 static inline bool msgpack_object_to_timestamp(const msgpack_object
* obj
, msgpack_timestamp
* ts
) {
26 if (obj
->type
!= MSGPACK_OBJECT_EXT
) return false;
27 if (obj
->via
.ext
.type
!= -1) return false;
28 switch (obj
->via
.ext
.size
) {
33 _msgpack_load32(uint32_t, obj
->via
.ext
.ptr
, &v
);
39 _msgpack_load64(uint64_t, obj
->via
.ext
.ptr
, &value
);
40 ts
->tv_nsec
= (uint32_t)(value
>> 34);
41 ts
->tv_sec
= value
& 0x00000003ffffffffLL
;
45 _msgpack_load32(uint32_t, obj
->via
.ext
.ptr
, &ts
->tv_nsec
);
46 _msgpack_load64(int64_t, obj
->via
.ext
.ptr
+ 4, &ts
->tv_sec
);
58 #endif /* msgpack/timestamp.h */
This page took 0.029658 seconds and 4 git commands to generate.