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; +} +