xref: /minix3/external/bsd/blacklist/port/clock_gettime.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc #ifdef HAVE_CONFIG_H
2*0a6a1f1dSLionel Sambuc #include "config.h"
3*0a6a1f1dSLionel Sambuc #endif
4*0a6a1f1dSLionel Sambuc 
5*0a6a1f1dSLionel Sambuc #include <time.h>
6*0a6a1f1dSLionel Sambuc #include <sys/time.h>
7*0a6a1f1dSLionel Sambuc 
8*0a6a1f1dSLionel Sambuc int
clock_gettime(int clock __unused,struct timespec * ts)9*0a6a1f1dSLionel Sambuc clock_gettime(int clock __unused, struct timespec *ts)
10*0a6a1f1dSLionel Sambuc {
11*0a6a1f1dSLionel Sambuc 	struct timeval tv;
12*0a6a1f1dSLionel Sambuc 	if (gettimeofday(&tv, NULL) == -1)
13*0a6a1f1dSLionel Sambuc 		return -1;
14*0a6a1f1dSLionel Sambuc 	ts->tv_sec = tv.tv_sec;
15*0a6a1f1dSLionel Sambuc 	ts->tv_nsec = tv.tv_usec * 1000;
16*0a6a1f1dSLionel Sambuc 	return 0;
17*0a6a1f1dSLionel Sambuc }
18