xref: /csrg-svn/sys/kern/kern_time.c (revision 7500)
1*7500Sroot /*	kern_time.c	5.2	82/07/24	*/
27424Sroot 
37424Sroot #include "../h/param.h"
47424Sroot #include "../h/systm.h"
57424Sroot #include "../h/dir.h"
67424Sroot #include "../h/user.h"
77424Sroot #include "../h/reg.h"
87424Sroot #include "../h/inode.h"
97424Sroot #include "../h/proc.h"
107424Sroot #include "../h/clock.h"
117424Sroot #include "../h/mtpr.h"
127424Sroot #include "../h/timeb.h"
137424Sroot #include "../h/times.h"
147424Sroot #include "../h/reboot.h"
157424Sroot #include "../h/fs.h"
167424Sroot #include "../h/conf.h"
177424Sroot #include "../h/buf.h"
187424Sroot #include "../h/mount.h"
197424Sroot 
20*7500Sroot rtime()
217424Sroot {
22*7500Sroot 
23*7500Sroot }
24*7500Sroot 
25*7500Sroot rusage()
26*7500Sroot {
27*7500Sroot 
28*7500Sroot }
29*7500Sroot 
30*7500Sroot itimer()
31*7500Sroot {
32*7500Sroot 
33*7500Sroot }
34*7500Sroot 
35*7500Sroot /* BEGIN DEPRECATED */
36*7500Sroot ogtime()
37*7500Sroot {
38*7500Sroot 
397424Sroot 	u.u_r.r_time = time;
407424Sroot 	if (clkwrap())
417424Sroot 		clkset();
427424Sroot }
437424Sroot 
447424Sroot /*
457424Sroot  * New time entry-- return TOD with milliseconds, timezone,
467424Sroot  * DST flag
477424Sroot  */
48*7500Sroot oftime()
497424Sroot {
507424Sroot 	register struct a {
517424Sroot 		struct	timeb	*tp;
527424Sroot 	} *uap;
537424Sroot 	struct timeb t;
547424Sroot 	register unsigned ms;
557424Sroot 
567424Sroot 	uap = (struct a *)u.u_ap;
577424Sroot 	(void) spl7();
587424Sroot 	t.time = time;
597424Sroot 	ms = lbolt;
607424Sroot 	(void) spl0();
617424Sroot 	if (ms > hz) {
627424Sroot 		ms -= hz;
637424Sroot 		t.time++;
647424Sroot 	}
657424Sroot 	t.millitm = (1000*ms)/hz;
667424Sroot 	t.timezone = timezone;
677424Sroot 	t.dstflag = dstflag;
687424Sroot 	if (copyout((caddr_t)&t, (caddr_t)uap->tp, sizeof(t)) < 0)
697424Sroot 		u.u_error = EFAULT;
707424Sroot 	if (clkwrap())
717424Sroot 		clkset();
727424Sroot }
73*7500Sroot /* END DEPRECATED */
747424Sroot 
757424Sroot /*
767424Sroot  * Set the time
777424Sroot  */
787424Sroot stime()
797424Sroot {
807424Sroot 	register struct a {
817424Sroot 		time_t	time;
827424Sroot 	} *uap;
837424Sroot 
847424Sroot 	uap = (struct a *)u.u_ap;
857424Sroot 	if (suser()) {
867424Sroot 		bootime += uap->time - time;
877424Sroot 		time = uap->time;
887424Sroot 		clkset();
897424Sroot 	}
907424Sroot }
917424Sroot 
927424Sroot times()
937424Sroot {
947424Sroot 	register struct a {
957424Sroot 		time_t	(*times)[4];
967424Sroot 	} *uap;
977424Sroot 	struct tms tms;
987424Sroot 
997424Sroot 	tms.tms_utime = u.u_vm.vm_utime;
1007424Sroot 	tms.tms_stime = u.u_vm.vm_stime;
1017424Sroot 	tms.tms_cutime = u.u_cvm.vm_utime;
1027424Sroot 	tms.tms_cstime = u.u_cvm.vm_stime;
1037424Sroot 	uap = (struct a *)u.u_ap;
1047424Sroot 	if (copyout((caddr_t)&tms, (caddr_t)uap->times, sizeof(struct tms)) < 0)
1057424Sroot 		u.u_error = EFAULT;
1067424Sroot }
107