time.h 556 B

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