net-snmp 5.7
gettimeofday.c
00001 /*
00002  * gettimeofday() replacement for MSVC.
00003  */
00004 
00005 #include <net-snmp/net-snmp-config.h>
00006 #include <net-snmp/types.h>
00007 
00008 #ifdef HAVE_SYS_TIMEB_H
00009 # include <sys/timeb.h> /* _ftime() */
00010 #endif
00011 #if TIME_WITH_SYS_TIME
00012 # include <sys/time.h>
00013 # include <time.h>
00014 #else
00015 # if HAVE_SYS_TIME_H
00016 #  include <sys/time.h>
00017 # else
00018 #  include <time.h>
00019 # endif
00020 #endif
00021 
00022 #include <net-snmp/library/system.h>
00023 
00024 int
00025 gettimeofday(struct timeval *tv, struct timezone *tz)
00026 {
00027     struct _timeb   timebuffer;
00028 
00029     _ftime(&timebuffer);
00030     tv->tv_usec = timebuffer.millitm * 1000;
00031     tv->tv_sec = (long)timebuffer.time;
00032     return (0);
00033 }