mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-04 05:15:07 -05:00
adopt struct timespec
Replace struct timeval with struct timespec as the main data type for timestamps. This will allow the NTP code to work with timestamps in nanosecond resolution.
This commit is contained in:
6
ntp_io.c
6
ntp_io.c
@@ -549,7 +549,7 @@ process_receive(struct msghdr *hdr, int length, int sock_fd)
|
||||
NTP_Remote_Address remote_addr;
|
||||
NTP_Local_Address local_addr;
|
||||
struct cmsghdr *cmsg;
|
||||
struct timeval now;
|
||||
struct timespec now;
|
||||
double now_err;
|
||||
|
||||
SCH_GetLastEventTime(&now, &now_err, NULL);
|
||||
@@ -590,9 +590,11 @@ process_receive(struct msghdr *hdr, int length, int sock_fd)
|
||||
#ifdef SO_TIMESTAMP
|
||||
if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SO_TIMESTAMP) {
|
||||
struct timeval tv;
|
||||
struct timespec ts;
|
||||
|
||||
memcpy(&tv, CMSG_DATA(cmsg), sizeof(tv));
|
||||
LCL_CookTime(&tv, &now, &now_err);
|
||||
UTI_TimevalToTimespec(&tv, &ts);
|
||||
LCL_CookTime(&ts, &now, &now_err);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user