1
0

clock_gettime32.c 376 B

123456789101112131415161718
  1. #include "time32.h"
  2. #include <time.h>
  3. #include <errno.h>
  4. #include <stdint.h>
  5. int __clock_gettime32(clockid_t clk, struct timespec32 *ts32)
  6. {
  7. struct timespec ts;
  8. int r = clock_gettime(clk, &ts);
  9. if (r) return r;
  10. if (ts.tv_sec < INT32_MIN || ts.tv_sec > INT32_MAX) {
  11. errno = EOVERFLOW;
  12. return -1;
  13. }
  14. ts32->tv_sec = ts.tv_sec;
  15. ts32->tv_nsec = ts.tv_nsec;
  16. return 0;
  17. }