time.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (c) 2017 Intel Corporation
  3. * Copyright (c) 2019 Peter Bigot Consulting, LLC
  4. *
  5. * SPDX-License-Identifier: Apache-2.0
  6. */
  7. #ifndef ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_TIME_H_
  8. #define ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_TIME_H_
  9. #include <stdint.h>
  10. #include <sys/_types.h>
  11. #include <bits/restrict.h>
  12. #include <sys/_timespec.h>
  13. /* Minimal time.h to fulfill the requirements of certain libraries
  14. * like mbedTLS and to support time APIs.
  15. */
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. struct tm {
  20. int tm_sec;
  21. int tm_min;
  22. int tm_hour;
  23. int tm_mday;
  24. int tm_mon;
  25. int tm_year;
  26. int tm_wday;
  27. int tm_yday;
  28. int tm_isdst;
  29. };
  30. #if !defined(__time_t_defined)
  31. #define __time_t_defined
  32. typedef _TIME_T_ time_t;
  33. #endif
  34. #if !defined(__suseconds_t_defined)
  35. #define __suseconds_t_defined
  36. typedef _SUSECONDS_T_ suseconds_t;
  37. #endif
  38. /*
  39. * Conversion between civil time and UNIX time. The companion
  40. * localtime() and inverse mktime() are not provided here since they
  41. * require access to time zone information.
  42. */
  43. struct tm *gmtime(const time_t *timep);
  44. struct tm *gmtime_r(const time_t *_MLIBC_RESTRICT timep,
  45. struct tm *_MLIBC_RESTRICT result);
  46. time_t time(time_t *tloc);
  47. #ifdef __cplusplus
  48. }
  49. #endif
  50. #endif /* ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_STDIO_H_ */