summaryrefslogtreecommitdiff
path: root/snmplib/gettimeofday.c
blob: df5c0a04d4a6bbfabb966c360607b3f83f58b780 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
 * gettimeofday() replacement for MSVC.
 */

#include <net-snmp/net-snmp-config.h>
#include <net-snmp/types.h>

#ifdef HAVE_SYS_TIMEB_H
# include <sys/timeb.h> /* _ftime() */
#endif
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
#  include <sys/time.h>
# else
#  include <time.h>
# endif
#endif

#include <net-snmp/library/system.h>

int
gettimeofday(struct timeval *tv, struct timezone *tz)
{
    struct _timeb   timebuffer;

    _ftime(&timebuffer);
    tv->tv_usec = timebuffer.millitm * 1000;
    tv->tv_sec = (long)timebuffer.time;
    return (0);
}