platform_timer.h 871 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * @Author: jiejie
  3. * @Github: https://github.com/jiejieTop
  4. * @Date: 2019-12-10 22:18:32
  5. * @LastEditTime: 2020-10-17 14:17:55
  6. * @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
  7. */
  8. #ifndef _PLATFORM_TIMER_H_
  9. #define _PLATFORM_TIMER_H_
  10. #include <sys/time.h>
  11. #include <stdio.h>
  12. #include <unistd.h>
  13. #include <time.h>
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. typedef struct platform_timer {
  18. struct timeval time;
  19. } platform_timer_t;
  20. void platform_timer_init(platform_timer_t* timer);
  21. void platform_timer_cutdown(platform_timer_t* timer, unsigned int timeout);
  22. char platform_timer_is_expired(platform_timer_t* timer);
  23. int platform_timer_remain(platform_timer_t* timer);
  24. unsigned long platform_timer_now(void);
  25. void platform_timer_usleep(unsigned long usec);
  26. #ifdef __cplusplus
  27. }
  28. #endif
  29. #endif