Use nanoseconds in timevals in cmdmon protocol
This commit is contained in:
parent
78f37e726a
commit
84f8463f2a
2 changed files with 3 additions and 3 deletions
2
candm.h
2
candm.h
|
@ -96,7 +96,7 @@
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t tv_sec_high;
|
uint32_t tv_sec_high;
|
||||||
uint32_t tv_sec_low;
|
uint32_t tv_sec_low;
|
||||||
uint32_t tv_usec;
|
uint32_t tv_nsec;
|
||||||
} Timeval;
|
} Timeval;
|
||||||
|
|
||||||
/* This is used in tv_sec_high for 32-bit timestamps */
|
/* This is used in tv_sec_high for 32-bit timestamps */
|
||||||
|
|
4
util.c
4
util.c
|
@ -493,7 +493,7 @@ UTI_TimevalNetworkToHost(Timeval *src, struct timeval *dest)
|
||||||
{
|
{
|
||||||
uint32_t sec_low, sec_high;
|
uint32_t sec_low, sec_high;
|
||||||
|
|
||||||
dest->tv_usec = ntohl(src->tv_usec);
|
dest->tv_usec = ntohl(src->tv_nsec) / 1000;
|
||||||
sec_high = ntohl(src->tv_sec_high);
|
sec_high = ntohl(src->tv_sec_high);
|
||||||
sec_low = ntohl(src->tv_sec_low);
|
sec_low = ntohl(src->tv_sec_low);
|
||||||
|
|
||||||
|
@ -514,7 +514,7 @@ UTI_TimevalNetworkToHost(Timeval *src, struct timeval *dest)
|
||||||
void
|
void
|
||||||
UTI_TimevalHostToNetwork(struct timeval *src, Timeval *dest)
|
UTI_TimevalHostToNetwork(struct timeval *src, Timeval *dest)
|
||||||
{
|
{
|
||||||
dest->tv_usec = htonl(src->tv_usec);
|
dest->tv_nsec = htonl(src->tv_usec * 1000);
|
||||||
if (sizeof (time_t) > 4)
|
if (sizeof (time_t) > 4)
|
||||||
dest->tv_sec_high = htonl(src->tv_sec >> 16 >> 16);
|
dest->tv_sec_high = htonl(src->tv_sec >> 16 >> 16);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue