1 /* kern_time.c 5.1 82/07/15 */ 2 3 #include "../h/param.h" 4 #include "../h/systm.h" 5 #include "../h/dir.h" 6 #include "../h/user.h" 7 #include "../h/reg.h" 8 #include "../h/inode.h" 9 #include "../h/proc.h" 10 #include "../h/clock.h" 11 #include "../h/mtpr.h" 12 #include "../h/timeb.h" 13 #include "../h/times.h" 14 #include "../h/reboot.h" 15 #include "../h/fs.h" 16 #include "../h/conf.h" 17 #include "../h/buf.h" 18 #include "../h/mount.h" 19 20 /* 21 * return the current time (old-style entry) 22 */ 23 gtime() 24 { 25 u.u_r.r_time = time; 26 if (clkwrap()) 27 clkset(); 28 } 29 30 /* 31 * New time entry-- return TOD with milliseconds, timezone, 32 * DST flag 33 */ 34 ftime() 35 { 36 register struct a { 37 struct timeb *tp; 38 } *uap; 39 struct timeb t; 40 register unsigned ms; 41 42 uap = (struct a *)u.u_ap; 43 (void) spl7(); 44 t.time = time; 45 ms = lbolt; 46 (void) spl0(); 47 if (ms > hz) { 48 ms -= hz; 49 t.time++; 50 } 51 t.millitm = (1000*ms)/hz; 52 t.timezone = timezone; 53 t.dstflag = dstflag; 54 if (copyout((caddr_t)&t, (caddr_t)uap->tp, sizeof(t)) < 0) 55 u.u_error = EFAULT; 56 if (clkwrap()) 57 clkset(); 58 } 59 60 /* 61 * Set the time 62 */ 63 stime() 64 { 65 register struct a { 66 time_t time; 67 } *uap; 68 69 uap = (struct a *)u.u_ap; 70 if (suser()) { 71 bootime += uap->time - time; 72 time = uap->time; 73 clkset(); 74 } 75 } 76 77 times() 78 { 79 register struct a { 80 time_t (*times)[4]; 81 } *uap; 82 struct tms tms; 83 84 tms.tms_utime = u.u_vm.vm_utime; 85 tms.tms_stime = u.u_vm.vm_stime; 86 tms.tms_cutime = u.u_cvm.vm_utime; 87 tms.tms_cstime = u.u_cvm.vm_stime; 88 uap = (struct a *)u.u_ap; 89 if (copyout((caddr_t)&tms, (caddr_t)uap->times, sizeof(struct tms)) < 0) 90 u.u_error = EFAULT; 91 } 92