Przeglądaj źródła

It is possible to have struct timeval but not gettimeofday.

svn:r2125
Nick Mathewson 20 lat temu
rodzic
commit
849e998ac6
3 zmienionych plików z 9 dodań i 5 usunięć
  1. 2 0
      configure.in
  2. 6 0
      src/common/util.c
  3. 1 5
      src/common/util.h

+ 2 - 0
configure.in

@@ -148,6 +148,8 @@ AC_CHECK_HEADERS(stdint.h sys/types.h inttypes.h sys/param.h sys/wait.h sys/limi
 AC_CHECK_FUNCS(gettimeofday ftime socketpair uname inet_aton strptime)
 AC_REPLACE_FUNCS(strlcat strlcpy)
 
+AC_CHECK_MEMBERS([struct timeval.tv_sec])
+
 dnl In case we aren't given a working stdint.h, we'll need to grow our own.
 dnl Watch out.
 

+ 6 - 0
src/common/util.c

@@ -31,6 +31,12 @@
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
+#ifndef HAVE_GETTIMEOFDAY
+#ifdef HAVE_FTIME
+#include <sys/timeb.h>
+#endif
+#endif
+
 #include "util.h"
 #include "log.h"
 #include "crypto.h"

+ 1 - 5
src/common/util.h

@@ -26,16 +26,12 @@
 #elif defined(_MSC_VER)
 #include <winsock.h>
 #endif
-#ifndef HAVE_GETTIMEOFDAY
-#ifdef HAVE_FTIME
-#define USING_FAKE_TIMEVAL
-#include <sys/timeb.h>
+#ifndef HAVE_STRUCT_TIMEVAL_TV_SEC
 struct timeval {
   time_t tv_sec;
   unsigned int tv_usec;
 };
 #endif
-#endif
 
 #ifdef MS_WINDOWS
 /* Windows names string functions differently from most other platforms. */