1 #include <sys/cdefs.h> 2 #include <lib.h> 3 #include "namespace.h" 4 5 #include <string.h> 6 #include <sys/time.h> 7 #include <time.h> 8 9 #ifdef __weak_alias 10 __weak_alias(adjtime, __adjtime50); 11 #endif 12 13 int adjtime(const struct timeval *delta, struct timeval *olddelta) 14 { 15 message m; 16 17 memset(&m, 0, sizeof(m)); 18 m.m_lc_pm_time.clk_id = CLOCK_REALTIME; 19 m.m_lc_pm_time.now = 0; /* use adjtime() method to slowly adjust the clock. */ 20 m.m_lc_pm_time.sec = delta->tv_sec; 21 m.m_lc_pm_time.nsec = delta->tv_usec * 1000; /* convert usec to nsec */ 22 23 if (_syscall(PM_PROC_NR, PM_CLOCK_SETTIME, &m) < 0) 24 return -1; 25 26 if (olddelta != NULL) { 27 /* the kernel returns immediately and the adjustment happens in the 28 * background. Also, any currently running adjustment is stopped by 29 * another call to adjtime(2), so the only values possible on Minix 30 * for olddelta are those of delta. 31 */ 32 olddelta->tv_sec = delta->tv_sec; 33 olddelta->tv_usec = delta->tv_usec; 34 } 35 36 return 0; 37 } 38 39