#define CLOCK_REALTIME 0 #define CLOCK_MONOTONIC 1 #define CLOCK_GETRES 0 #define CLOCK_GETTIME 1 #define CLOCK_SETTIME 2 int clock(int operation, int clock_id, struct timespec *time);
This syscall fetches or sets epoch dates for each of the supported clocks.
Clock is passed in clock_id, with the following values.
CLOCK_REALTIMEWall-clock, may jump forward and back thanks to time setting.
CLOCK_MONOTONICClock that only moves forward, and is unaffected by NTP or adjustments. It starts from an unspecified, target-dependent point in time, usually boot.
Unlike Linux, it is still counted during suspend.
operation specifies what to do, as such:
CLOCK_GETRESLoad the resolution of the passed clock on the contents of time.
CLOCK_GETTIMELoad the epoch date of the passed clock on the contents of time.
CLOCK_SETTIMESet the epoch date of the passed clock to the contents of time, not
supported for CLOCK_MONOTONIC. Underlying hardware will always be
updated.
The syscall returns 0 on success or -1 on failure, with the
following errno:
EFAULTtime points to non accessible memory.
EINVALOne of the passed values is not valid.