xref: /plan9-contrib/sys/src/ape/lib/ap/plan9/time.c (revision fb7f0c934c48abaed6040d054ef636408c3c522d)
1 #include <sys/types.h>
2 #include <sys/stat.h>
3 #include <fcntl.h>
4 #include <time.h>
5 #include <unistd.h>
6 #include <string.h>
7 #include <stdlib.h>
8 #include "sys9.h"
9 
10 time_t
time(time_t * tp)11 time(time_t *tp)
12 {
13 	char b[20];
14 	int f;
15 	time_t t;
16 
17 	memset(b, 0, sizeof(b));
18 	f = _OPEN("/dev/time", 0);
19 	if(f >= 0) {
20 		_PREAD(f, b, sizeof(b), 0);
21 		_CLOSE(f);
22 	}
23 	t = atol(b);
24 	if(tp)
25 		*tp = t;
26 	return t;
27 }
28