xref: /linux/tools/include/nolibc/time.h (revision 3785289f97e2118b157332ffaae9fd2ec71237c8)
1 /* SPDX-License-Identifier: LGPL-2.1 OR MIT */
2 /*
3  * time function definitions for NOLIBC
4  * Copyright (C) 2017-2022 Willy Tarreau <w@1wt.eu>
5  */
6 
7 /* make sure to include all global symbols */
8 #include "nolibc.h"
9 
10 #ifndef _NOLIBC_TIME_H
11 #define _NOLIBC_TIME_H
12 
13 #include "std.h"
14 #include "arch.h"
15 #include "types.h"
16 #include "sys.h"
17 
18 static __attribute__((unused))
19 time_t time(time_t *tptr)
20 {
21 	struct timeval tv;
22 
23 	/* note, cannot fail here */
24 	sys_gettimeofday(&tv, NULL);
25 
26 	if (tptr)
27 		*tptr = tv.tv_sec;
28 	return tv.tv_sec;
29 }
30 
31 #endif /* _NOLIBC_TIME_H */
32