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

     1  #include "time32.h"
     2  #include <sys/time.h>
     3  #include <errno.h>
     4  #include <stdint.h>
     5  
     6  int __gettimeofday_time32(struct timeval32 *tv32, void *tz)
     7  {
     8  	struct timeval tv;
     9  	if (!tv32) return 0;
    10  	int r = gettimeofday(&tv, 0);
    11  	if (r) return r;
    12  	if (tv.tv_sec < INT32_MIN || tv.tv_sec > INT32_MAX) {
    13  		errno = EOVERFLOW;
    14  		return -1;
    15  	}
    16  	tv32->tv_sec = tv.tv_sec;
    17  	tv32->tv_usec = tv.tv_usec;
    18  	return 0;
    19  }