1
0

clock_time.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) 2006-2021, 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. /* posix clock and timer */
  13. #define MILLISECOND_PER_SECOND 1000UL
  14. #define MICROSECOND_PER_SECOND 1000000UL
  15. #define NANOSECOND_PER_SECOND 1000000000UL
  16. #define MILLISECOND_PER_TICK (MILLISECOND_PER_SECOND / RT_TICK_PER_SECOND)
  17. #define MICROSECOND_PER_TICK (MICROSECOND_PER_SECOND / RT_TICK_PER_SECOND)
  18. #define NANOSECOND_PER_TICK (NANOSECOND_PER_SECOND / RT_TICK_PER_SECOND)
  19. #ifndef CLOCK_REALTIME
  20. #define CLOCK_REALTIME 1
  21. #endif
  22. #define CLOCK_CPUTIME_ID 2
  23. #ifndef CLOCK_PROCESS_CPUTIME_ID
  24. #define CLOCK_PROCESS_CPUTIME_ID CLOCK_CPUTIME_ID
  25. #endif
  26. #ifndef CLOCK_THREAD_CPUTIME_ID
  27. #define CLOCK_THREAD_CPUTIME_ID CLOCK_CPUTIME_ID
  28. #endif
  29. #ifndef CLOCK_MONOTONIC
  30. #define CLOCK_MONOTONIC 4
  31. #endif
  32. int clock_getres (clockid_t clockid, struct timespec *res);
  33. int clock_gettime (clockid_t clockid, struct timespec *tp);
  34. int clock_settime (clockid_t clockid, const struct timespec *tp);
  35. #endif