clock_time.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2017-12-31 Bernard the first version
  9. */
  10. #ifndef CLOCK_TIME_H__
  11. #define CLOCK_TIME_H__
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. /* posix clock and timer */
  16. #define MILLISECOND_PER_SECOND 1000UL
  17. #define MICROSECOND_PER_SECOND 1000000UL
  18. #define NANOSECOND_PER_SECOND 1000000000UL
  19. #define MILLISECOND_PER_TICK (MILLISECOND_PER_SECOND / RT_TICK_PER_SECOND)
  20. #define MICROSECOND_PER_TICK (MICROSECOND_PER_SECOND / RT_TICK_PER_SECOND)
  21. #define NANOSECOND_PER_TICK (NANOSECOND_PER_SECOND / RT_TICK_PER_SECOND)
  22. #ifndef CLOCK_REALTIME
  23. #define CLOCK_REALTIME 1
  24. #endif
  25. #define CLOCK_CPUTIME_ID 2
  26. #ifndef CLOCK_PROCESS_CPUTIME_ID
  27. #define CLOCK_PROCESS_CPUTIME_ID CLOCK_CPUTIME_ID
  28. #endif
  29. #ifndef CLOCK_THREAD_CPUTIME_ID
  30. #define CLOCK_THREAD_CPUTIME_ID CLOCK_CPUTIME_ID
  31. #endif
  32. #ifndef CLOCK_MONOTONIC
  33. #define CLOCK_MONOTONIC 4
  34. #endif
  35. int clock_getres (clockid_t clockid, struct timespec *res);
  36. int clock_gettime (clockid_t clockid, struct timespec *tp);
  37. int clock_settime (clockid_t clockid, const struct timespec *tp);
  38. #ifdef __cplusplus
  39. }
  40. #endif
  41. #endif