1570af302Sopenharmony_ci#include "time32.h" 2570af302Sopenharmony_ci#include <time.h> 3570af302Sopenharmony_ci#include <errno.h> 4570af302Sopenharmony_ci#include <stdint.h> 5570af302Sopenharmony_ci 6570af302Sopenharmony_ciint __clock_gettime32(clockid_t clk, struct timespec32 *ts32) 7570af302Sopenharmony_ci{ 8570af302Sopenharmony_ci struct timespec ts; 9570af302Sopenharmony_ci int r = clock_gettime(clk, &ts); 10570af302Sopenharmony_ci if (r) return r; 11570af302Sopenharmony_ci if (ts.tv_sec < INT32_MIN || ts.tv_sec > INT32_MAX) { 12570af302Sopenharmony_ci errno = EOVERFLOW; 13570af302Sopenharmony_ci return -1; 14570af302Sopenharmony_ci } 15570af302Sopenharmony_ci ts32->tv_sec = ts.tv_sec; 16570af302Sopenharmony_ci ts32->tv_nsec = ts.tv_nsec; 17570af302Sopenharmony_ci return 0; 18570af302Sopenharmony_ci} 19