shithub: riscv

ref: 1d07c2a1614a3121a5b9d86f95394caccd61ee56
dir: /sys/src/ape/lib/ap/plan9/time.c/

View raw version
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include "sys9.h"

time_t
time(time_t *tp)
{
	char b[20];
	int f;
	time_t t;

	memset(b, 0, sizeof(b));
	f = _OPEN("/dev/time", OREAD);
	if(f >= 0) {
		_PREAD(f, b, sizeof(b), 0);
		_CLOSE(f);
	}
	t = atol(b);
	if(tp)
		*tp = t;
	return t;
}