xref: /linux/tools/include/nolibc/time.h (revision ed5c2f5fd10dda07263f79f338a512c0f49f76f5)
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 #ifndef _NOLIBC_TIME_H
8 #define _NOLIBC_TIME_H
9 
10 #include "std.h"
11 #include "arch.h"
12 #include "types.h"
13 #include "sys.h"
14 
15 static __attribute__((unused))
16 time_t time(time_t *tptr)
17 {
18 	struct timeval tv;
19 
20 	/* note, cannot fail here */
21 	sys_gettimeofday(&tv, NULL);
22 
23 	if (tptr)
24 		*tptr = tv.tv_sec;
25 	return tv.tv_sec;
26 }
27 
28 #endif /* _NOLIBC_TIME_H */
29