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