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