[git] GnuPG - branch, master, updated. gnupg-2.1.15-308-gad491ce

by Werner Koch cvs at cvs.gnupg.org
Mon Oct 31 12:29:05 CET 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".

The branch, master has been updated
       via  ad491ceec6145b3781a05dc7b4a36052abeeb4b4 (commit)
      from  3b6b8fe32af7568ff51066d4c2e3679df6dea86f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ad491ceec6145b3781a05dc7b4a36052abeeb4b4
Author: Werner Koch <wk at gnupg.org>
Date:   Mon Oct 31 12:20:33 2016 +0100

    common: New function gnupg_usleep.
    
    * configure.ac (HAVE_NANOSLEEP): Test for nanosleep.
    * common/sysutils.c: Always include time.h.
    (gnupg_usleep): New.
    --
    
    This function has been compiled from nPth and Libassuan.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/common/sysutils.c b/common/sysutils.c
index 6eea90e..28d4cde 100644
--- a/common/sysutils.c
+++ b/common/sysutils.c
@@ -49,8 +49,8 @@
 # include <asm/sysinfo.h>
 # include <asm/unistd.h>
 #endif
+#include <time.h>
 #ifdef HAVE_SETRLIMIT
-# include <time.h>
 # include <sys/time.h>
 # include <sys/resource.h>
 #endif
@@ -307,6 +307,50 @@ gnupg_sleep (unsigned int seconds)
 }
 
 
+/* Wrapper around the platforms usleep function.  This one won't wake
+ * up before the sleep time has really elapsed.  When build with nPth
+ * it merely calls npth_usleep and thus suspends only the current
+ * thread. */
+void
+gnupg_usleep (unsigned int usecs)
+{
+#if defined(USE_NPTH)
+
+  npth_usleep (usecs);
+
+#elif defined(HAVE_W32_SYSTEM)
+
+  Sleep ((usecs + 999) / 1000);
+
+#elif defined(HAVE_NANOSLEEP)
+
+  if (usecs)
+    {
+      struct timespec req;
+      struct timespec rem;
+
+      req.tv_sec = 0;
+      req.tv_nsec = usecs * 1000;
+
+      while (nanosleep (&req, &rem) < 0 && errno == EINTR)
+        req = rem;
+    }
+
+#else /*Standard Unix*/
+
+  if (usecs)
+    {
+      struct timeval tv;
+
+      tv.tv_sec  = usecs / 1000000;
+      tv.tv_usec = usecs % 1000000;
+      select (0, NULL, NULL, NULL, &tv);
+    }
+
+#endif
+}
+
+
 /* This function is a NOP for POSIX systems but required under Windows
    as the file handles as returned by OS calls (like CreateFile) are
    different from the libc file descriptors (like open). This function
diff --git a/common/sysutils.h b/common/sysutils.h
index 7105107..5467b4c 100644
--- a/common/sysutils.h
+++ b/common/sysutils.h
@@ -54,6 +54,7 @@ const unsigned char *get_session_marker (size_t *rlen);
 unsigned int get_uint_nonce (void);
 /*int check_permissions (const char *path,int extension,int checkonly);*/
 void gnupg_sleep (unsigned int seconds);
+void gnupg_usleep (unsigned int usecs);
 int translate_sys2libc_fd (gnupg_fd_t fd, int for_write);
 int translate_sys2libc_fd_int (int fd, int for_write);
 FILE *gnupg_tmpfile (void);
diff --git a/configure.ac b/configure.ac
index 91ef5c9..c211979 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1387,6 +1387,16 @@ AC_CHECK_FUNCS([memicmp stpcpy strsep strlwr strtoul memmove stricmp strtol \
                 flockfile funlockfile getpwnam getpwuid \
                 getenv inet_pton strpbrk])
 
+# On some systems (e.g. Solaris) nanosleep requires linking to librl.
+# Given that we use nanosleep only as an optimization over a select
+# based wait function we want it only if it is available in libc.
+_save_libs="$LIBS"
+AC_SEARCH_LIBS([nanosleep], [],
+               [AC_DEFINE(HAVE_NANOSLEEP,1,
+                [Define to 1 if you have the `nanosleep' function in libc.])])
+LIBS="$_save_libs"
+
+
 # See whether libc supports the Linux inotify interface
 case "${host}" in
     *-*-linux*)

-----------------------------------------------------------------------

Summary of changes:
 common/sysutils.c | 46 +++++++++++++++++++++++++++++++++++++++++++++-
 common/sysutils.h |  1 +
 configure.ac      | 10 ++++++++++
 3 files changed, 56 insertions(+), 1 deletion(-)


hooks/post-receive
-- 
The GNU Privacy Guard
http://git.gnupg.org




More information about the Gnupg-commits mailing list