From 0dced917ada461fa611fbcd69f83082a976d519e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Fillod=2C=20F8CFE?= Date: Sun, 17 Aug 2003 22:33:37 +0000 Subject: [PATCH] gettimeofday replacement for WIN32 git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@1509 7ae35d74-ebe9-4afe-98af-79ac388436b8 --- configure.ac | 4 ++-- lib/Makefile.am | 2 +- lib/gettimeofday.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 lib/gettimeofday.c diff --git a/configure.ac b/configure.ac index 4fca9aed3..b2747a041 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/lib/Makefile.am b/lib/Makefile.am index 6f3b46051..7df9e3b14 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -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 diff --git a/lib/gettimeofday.c b/lib/gettimeofday.c new file mode 100644 index 000000000..da6974077 --- /dev/null +++ b/lib/gettimeofday.c @@ -0,0 +1,35 @@ + +#include + +#ifdef HAVE_WINDOWS_H +#include +#endif +#ifdef HAVE_WINBASE_H +# include +#endif + +#include + +#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; +} +