github.com/afumu/libc@v0.0.6/musl/compat/time32/clock_gettime32.c (about)

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