xref: /openbsd-src/gnu/lib/libiberty/src/gettimeofday.c (revision 20fce977aadac3358da45d5027d7d19cdc03b0fe)
1*20fce977Smiod #include "config.h"
2*20fce977Smiod #include "libiberty.h"
3*20fce977Smiod #ifdef HAVE_TIME_H
4*20fce977Smiod #include <time.h>
5*20fce977Smiod #endif
6*20fce977Smiod #ifdef HAVE_SYS_TIME_H
7*20fce977Smiod #include <sys/time.h>
8*20fce977Smiod #endif
9*20fce977Smiod 
10*20fce977Smiod /*
11*20fce977Smiod 
12*20fce977Smiod @deftypefn Supplemental int gettimeofday (struct timeval *@var{tp}, void *@var{tz})
13*20fce977Smiod 
14*20fce977Smiod Writes the current time to @var{tp}.  This implementation requires
15*20fce977Smiod that @var{tz} be NULL.  Returns 0 on success, -1 on failure.
16*20fce977Smiod 
17*20fce977Smiod @end deftypefn
18*20fce977Smiod 
19*20fce977Smiod */
20*20fce977Smiod 
21*20fce977Smiod int
gettimeofday(struct timeval * tp,void * tz)22*20fce977Smiod gettimeofday (struct timeval *tp, void *tz)
23*20fce977Smiod {
24*20fce977Smiod   if (tz)
25*20fce977Smiod     abort ();
26*20fce977Smiod   tp->tv_usec = 0;
27*20fce977Smiod   if (time (&tp->tv_sec) == (time_t) -1)
28*20fce977Smiod     return -1;
29*20fce977Smiod   return 0;
30*20fce977Smiod }
31