[Pkg-privacy-commits] [onioncat] 51/340: replaced clock_gettime by gettimeofday

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 13:04:24 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch debian
in repository onioncat.

commit b1ccc3b6b030871e2482dfdf5ea58808705c75a6
Author: eagle <eagle at 58e1ccc2-750e-0410-8d0d-f93ca75ab447>
Date:   Thu Apr 24 08:19:43 2008 +0000

    replaced clock_gettime by gettimeofday
    
    git-svn-id: http://www.cypherpunk.at/svn/onioncat/trunk@204 58e1ccc2-750e-0410-8d0d-f93ca75ab447
---
 config.h.in     |  3 ---
 configure       | 72 +--------------------------------------------------------
 configure.ac    |  2 +-
 src/ocatroute.c | 16 +++++++++++++
 4 files changed, 18 insertions(+), 75 deletions(-)

diff --git a/config.h.in b/config.h.in
index 6e0de65..a59ea71 100644
--- a/config.h.in
+++ b/config.h.in
@@ -3,9 +3,6 @@
 /* Define to 1 if you have the `pthread' library (-lpthread). */
 #undef HAVE_LIBPTHREAD
 
-/* Define to 1 if you have the `rt' library (-lrt). */
-#undef HAVE_LIBRT
-
 /* Define to 1 if you have the <linux/if_tun.h> header file. */
 #undef HAVE_LINUX_IF_TUN_H
 
diff --git a/configure b/configure
index 1f07833..ff3f73e 100755
--- a/configure
+++ b/configure
@@ -3337,77 +3337,7 @@ _ACEOF
 
 fi
 
-
-{ echo "$as_me:$LINENO: checking for clock_gettime in -lrt" >&5
-echo $ECHO_N "checking for clock_gettime in -lrt... $ECHO_C" >&6; }
-if test "${ac_cv_lib_rt_clock_gettime+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lrt  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char clock_gettime ();
-int
-main ()
-{
-return clock_gettime ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
-  ac_cv_lib_rt_clock_gettime=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_lib_rt_clock_gettime=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_rt_clock_gettime" >&5
-echo "${ECHO_T}$ac_cv_lib_rt_clock_gettime" >&6; }
-if test $ac_cv_lib_rt_clock_gettime = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBRT 1
-_ACEOF
-
-  LIBS="-lrt $LIBS"
-
-fi
-
+#AC_CHECK_LIB([rt], [clock_gettime])
 
 # Checks for header files.
 #AC_HEADER_STDC
diff --git a/configure.ac b/configure.ac
index 469da77..30c5ae2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,7 +15,7 @@ AC_PROG_CC
 
 # Checks for libraries.
 AC_CHECK_LIB([pthread], [pthread_create])
-AC_CHECK_LIB([rt], [clock_gettime])
+#AC_CHECK_LIB([rt], [clock_gettime])
 
 # Checks for header files.
 #AC_HEADER_STDC
diff --git a/src/ocatroute.c b/src/ocatroute.c
index e908f33..b93a06c 100644
--- a/src/ocatroute.c
+++ b/src/ocatroute.c
@@ -16,6 +16,7 @@
 #include <pthread.h>
 #include <arpa/inet.h>
 #include <errno.h>
+#include <sys/time.h>
 #include <sys/select.h>
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -208,6 +209,7 @@ void *packet_dequeuer(void *p)
 {
    PacketQueue_t **queue, *fqueue;
    struct timespec ts;
+   struct timeval tv;
    int rc, timed = 0;
    time_t delay;
 
@@ -216,7 +218,21 @@ void *packet_dequeuer(void *p)
       pthread_mutex_lock(&queue_mutex_);
       if (timed)
       {
+#ifdef USE_CLOCK_GETTIME
          clock_gettime(CLOCK_REALTIME, &ts);
+#else
+          // replaced clock_gettime() due to portability issues
+         if (gettimeofday(&tv, NULL) == -1)
+         {
+            log_msg(L_ERROR, "couldn't gettime: \"%s\"", strerror(errno));
+            memset(&tv, 0, sizeof(tv));
+         }
+         else
+         {
+            ts.tv_sec = tv.tv_sec;
+            ts.tv_nsec = tv.tv_usec * 1000;
+         }
+#endif
          ts.tv_sec += DEQUEUER_WAKEUP;
          log_msg(L_DEBUG, "timed conditional wait...");
          rc = pthread_cond_timedwait(&queue_cond_, &queue_mutex_, &ts);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onioncat.git



More information about the Pkg-privacy-commits mailing list