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:
Miroslav Lichvar
2016-08-17 16:05:53 +02:00
parent 0899ab52dd
commit d0dfa1de9e
46 changed files with 685 additions and 654 deletions

View File

@@ -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
}