summaryrefslogtreecommitdiff
path: root/lib/libc/time/time.c
blob: 134eed7b1ae9943979c1471f575b3376f4fb87ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <time.h>
#include <asm/vdso.h>
#include <syscall.h>

time_t time(time_t *tloc)
{
	struct timespec ts;

#if defined(__x86_64__)
	if (__vdso_time)
		return __vdso_time(tloc);
#endif

	clock_gettime(CLOCK_REALTIME, &ts);

	if (tloc)
		*tloc = ts.tv_sec;

	return ts.tv_sec;
}