summaryrefslogtreecommitdiff
path: root/lib/libc/time/time.c
blob: 3f8848a868d4a040e95dec7a4e50d6a2fa45c14e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <asm/vdso.h> // for __vdso_time
#include <time.h>     // for timespec, clock_gettime, time_t, CLOCK_REALTIME

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;
}