gettimeofday replacement for WIN32

git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@1509 7ae35d74-ebe9-4afe-98af-79ac388436b8
Hamlib-1.2.0
Stéphane Fillod, F8CFE 2003-08-17 22:33:37 +00:00
rodzic 4e483641c2
commit 0dced917ad
3 zmienionych plików z 38 dodań i 3 usunięć

Wyświetl plik

@ -131,10 +131,10 @@ AC_SUBST(MATH_LIBS)
AC_CHECK_LIB(syslog,syslog) # OS/2 needs this
dnl Checks for library functions.
AC_CHECK_FUNCS([atexit snprintf select gettimeofday memmove memset])
AC_CHECK_FUNCS([atexit snprintf select memmove memset])
AC_CHECK_FUNCS([strcasecmp strchr strdup strerror strrchr strstr strtol])
AC_CHECK_FUNCS([cfmakeraw setitimer])
AC_REPLACE_FUNCS([getopt_long usleep])
AC_REPLACE_FUNCS([getopt_long usleep gettimeofday])
AC_FUNC_ALLOCA
#AC_FUNC_MALLOC
AC_FUNC_VPRINTF

Wyświetl plik

@ -1,5 +1,5 @@
EXTRA_DIST = getopt.c getopt.h getopt_long.c usleep.c \
termios.c win32termios.h
termios.c win32termios.h gettimeofday.c
noinst_LTLIBRARIES = libmisc.la

35
lib/gettimeofday.c 100644
Wyświetl plik

@ -0,0 +1,35 @@
#include <config.h>
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif
#ifdef HAVE_WINBASE_H
# include <winbase.h>
#endif
#include <sys/time.h>
#ifndef timezone
struct timezone {
int tz_minuteswest;
int tz_dsttime;
};
#endif
/*
* broken implementation for WIN32.
* FIXME: usec precision
*/
int gettimeofday(struct timeval *tv, struct timezone *tz)
{
if (tv) {
time_t tm;
time(&tm);
tv->tv_sec = tm;
tv->tv_usec = 0;
}
return 0;
}