timespec_get_time32.c raw
1 #include "time32.h"
2 #include <time.h>
3 #include <errno.h>
4 #include <stdint.h>
5
6 int __timespec_get_time32(struct timespec32 *ts32, int base)
7 {
8 struct timespec ts;
9 int r = timespec_get(&ts, base);
10 if (!r) return r;
11 if (ts.tv_sec < INT32_MIN || ts.tv_sec > INT32_MAX) {
12 errno = EOVERFLOW;
13 return 0;
14 }
15 ts32->tv_sec = ts.tv_sec;
16 ts32->tv_nsec = ts.tv_nsec;
17 return r;
18 }
19