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