shithub: scc

ref: f62d7c3902ca10bd47531605d41948c88ade377b
dir: /src/libc/arch/posix/clock.c/

View raw version
#include "clock.h"

extern int _getrusage(int, struct rusage*);

static clock_t
convtick(struct rusage r)
{
	return r.ru_utime.tv_sec*CLOCKS_PER_SEC +
	       r.ru_stime.tv_usec / (1000000 / CLOCKS_PER_SEC);
}


clock_t
clock(void)
{
	struct rusage ru;
	clock_t c;

	if (_getrusage(RUSAGE_SELF, &ru))
		return ((clock_t) -1);
	return convtick(ru);
}