diff --git a/configure.ac b/configure.ac index 1e10a09..5652ede 100644 --- a/configure.ac +++ b/configure.ac @@ -9,8 +9,6 @@ AM_SILENT_RULES([yes]) AC_CONFIG_SRCDIR([common.h]) AC_PROG_CC_C99 AC_USE_SYSTEM_EXTENSIONS -AC_SEARCH_LIBS([clock_gettime], [rt], - [AC_DEFINE(HAVE_CLOCK_GETTIME,[1],[define if you have clock_gettime()])]) AC_SEARCH_LIBS([getaddrinfo], [resolv nsl]) AC_SEARCH_LIBS([socket], [socket]) PKG_CHECK_MODULES([libsodium], [libsodium >= 1.0.4]) diff --git a/main.c b/main.c index c3706bc..70071c8 100644 --- a/main.c +++ b/main.c @@ -6,8 +6,8 @@ #include #include #include -#include +#include #include #include #include @@ -22,10 +22,6 @@ #include -#if !defined(CLOCK_MONOTONIC_COARSE) && defined(CLOCK_MONOTONIC) -# define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC -#endif - #define GT_BUFFER_SIZE (4*1024*1024) struct netio { @@ -44,11 +40,11 @@ struct crypto_ctx { volatile sig_atomic_t running; -static int64_t dt_ms (struct timespec *ta, struct timespec *tb) +static int64_t dt_ms (struct timeval *ta, struct timeval *tb) { const int64_t s = ta->tv_sec-tb->tv_sec; - const int64_t n = ta->tv_nsec-tb->tv_nsec; - return s*1000LL+n/1000000LL; + const int64_t n = ta->tv_usec-tb->tv_usec; + return s*1000LL+n/1000LL; } static void fd_set_nonblock (int fd) @@ -555,7 +551,7 @@ int main (int argc, char **argv) #ifdef TCP_INFO struct { - struct timespec time; + struct timeval time; struct tcp_info info; } tcpinfo = {0}; #endif @@ -656,9 +652,9 @@ int main (int argc, char **argv) return 1; } -#if defined(CLOCK_MONOTONIC_COARSE) && defined(TCP_INFO) - struct timespec now; - clock_gettime(CLOCK_MONOTONIC_COARSE, &now); +#ifdef TCP_INFO + struct timeval now; + gettimeofday(&now, NULL); if (dt_ms(&now, &tcpinfo.time)>1000LL) { tcpinfo.time = now;