libc: add clock_settime() system call.
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.
This commit is contained in:
@@ -59,6 +59,7 @@ SRCS+= \
|
||||
sys_schedule.c \
|
||||
sys_setalarm.c \
|
||||
sys_setgrant.c \
|
||||
sys_settime.c \
|
||||
sys_sigreturn.c \
|
||||
sys_sigsend.c \
|
||||
sys_sprof.c \
|
||||
|
||||
20
lib/libsys/sys_settime.c
Normal file
20
lib/libsys/sys_settime.c
Normal file
@@ -0,0 +1,20 @@
|
||||
#include "syslib.h"
|
||||
#include <time.h>
|
||||
|
||||
int sys_settime(now, clk_id, sec, nsec)
|
||||
int now;
|
||||
clockid_t clk_id;
|
||||
time_t sec;
|
||||
long nsec;
|
||||
{
|
||||
message m;
|
||||
int r;
|
||||
|
||||
m.T_SETTIME_NOW = now;
|
||||
m.T_CLOCK_ID = clk_id;
|
||||
m.T_TIME_SEC = sec;
|
||||
m.T_TIME_NSEC = nsec;
|
||||
|
||||
r = _kernel_call(SYS_SETTIME, &m);
|
||||
return(r);
|
||||
}
|
||||
Reference in New Issue
Block a user