This also adds the sys_settime() kernel call which allows for the adjusting of the clock named realtime in the kernel. The existing sys_stime() function is still needed for a separate job (setting the boottime). The boottime is set in the readclock driver. The sys_settime() interface is meant to be flexible and will support both clock_settime() and adjtime() when adjtime() is implemented later. settimeofday() was adjusted to use the clock_settime() interface. One side note discovered during testing: uptime(1) (part of the last(1)), uses wtmp to determine boottime (not Minix's times(2)). This leads `uptime` to report odd results when you set the time to a time prior to boottime. This isn't a new bug introduced by my changes. It's been there for a while.
25 lines
423 B
C
25 lines
423 B
C
#include <sys/cdefs.h>
|
|
#include <lib.h>
|
|
#include "namespace.h"
|
|
|
|
#include <sys/time.h>
|
|
|
|
#ifdef __weak_alias
|
|
__weak_alias(clock_gettime, __clock_gettime50);
|
|
#endif
|
|
|
|
int clock_gettime(clockid_t clock_id, struct timespec *res)
|
|
{
|
|
message m;
|
|
|
|
m.m2_i1 = (clockid_t) clock_id;
|
|
|
|
if (_syscall(PM_PROC_NR, CLOCK_GETTIME, &m) < 0)
|
|
return -1;
|
|
|
|
res->tv_sec = (time_t) m.m2_l1;
|
|
res->tv_nsec = (long) m.m2_l2;
|
|
|
|
return 0;
|
|
}
|
|
|