xref: /openbmc/linux/tools/include/nolibc/time.h (revision 55abdd1f)
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))
time(time_t * tptr)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 /* make sure to include all global symbols */
29 #include "nolibc.h"
30 
31 #endif /* _NOLIBC_TIME_H */
32