ntp_gettime(3) | Library Functions Manual | ntp_gettime(3) |
ntp_gettime, ntp_gettimex - get time parameters (NTP daemon interface)
Standard C library (libc, -lc)
#include <sys/timex.h>
int ntp_gettime(struct ntptimeval *ntv); int ntp_gettimex(struct ntptimeval *ntv);
Both of these APIs return information to the caller via the ntv argument, a structure of the following type:
struct ntptimeval { struct timeval time; /* Current time */ long maxerror; /* Maximum error */ long esterror; /* Estimated error */ long tai; /* TAI offset */ /* Further padding bytes allowing for future expansion */ };
The fields of this structure are as follows:
struct timeval { time_t tv_sec; /* Seconds since the Epoch */ suseconds_t tv_usec; /* Microseconds */ };
ntp_gettime() returns an ntptimeval structure in which the time, maxerror, and esterror fields are filled in.
ntp_gettimex() performs the same task as ntp_gettime(), but also returns information in the tai field.
The return values for ntp_gettime() and ntp_gettimex() are as for adjtimex(2). Given a correct pointer argument, these functions always succeed.
For an explanation of the terms used in this section, see attributes(7).
Interface | Attribute | Value |
ntp_gettime (), ntp_gettimex () | Thread safety | MT-Safe |
adjtimex(2), ntp_adjtime(3), time(7)
2023-10-31 | Linux man-pages 6.7 |