summaryrefslogtreecommitdiff
path: root/src/time/clock.c
blob: 78403af3c259c79aa6d3390f7a2c801b7cd12b4a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <time.h>
#include <sys/times.h>
#include "syscall.h"

int __clock_gettime(clockid_t, struct timespec *);

clock_t clock()
{
	struct timespec ts;
	struct tms tms;
	if (!__clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts))
		return ts.tv_sec*1000000 + ts.tv_nsec/1000;
	__syscall(SYS_times, &tms);
	return (tms.tms_utime + tms.tms_stime)*10000;
}