time64_helpers.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef _TIME64_HELPERS_H
  2. #define _TIME64_HELPERS_H
  3. #include <linux/version.h>
  4. #include <bits/types.h>
  5. #include <time.h>
  6. #include <stddef.h>
  7. #if defined(__UCLIBC_USE_TIME64__) && __TARGET_ARCH_BITS__ == 32 && LINUX_VERSION_CODE < KERNEL_VERSION(5,1,0)
  8. #error 64bit time on 32bit targets is not supported on Linux < 5.1.0
  9. #endif
  10. struct __ts64_struct {
  11. __S64_TYPE tv_sec;
  12. __S64_TYPE tv_nsec;
  13. };
  14. #define TO_TS64_P(__ts) (((struct timespec *)(__ts)) ? \
  15. (&(struct __ts64_struct) {.tv_sec = ((struct timespec *)(__ts))->tv_sec, \
  16. .tv_nsec = ((struct timespec *)(__ts))->tv_nsec}) : NULL)
  17. struct __its64_struct {
  18. __S64_TYPE interval_tv_sec;
  19. __S64_TYPE interval_tv_nsec;
  20. __S64_TYPE value_tv_sec;
  21. __S64_TYPE value_tv_nsec;
  22. };
  23. #define TO_ITS64_P(__its) (((struct itimerspec *)(__its)) ? \
  24. (&(struct __its64_struct) {.interval_tv_sec = ((struct itimerspec *)(__its))->it_interval.tv_sec, \
  25. .interval_tv_nsec = ((struct itimerspec *)(__its))->it_interval.tv_nsec, \
  26. .value_tv_sec = ((struct itimerspec *)(__its))->it_value.tv_sec, \
  27. .value_tv_nsec = ((struct itimerspec *)(__its))->it_value.tv_nsec}) : NULL)
  28. #endif /* _TIME64_HELPERS_H */