[git] GnuPG - branch, master, updated. gnupg-2.2.1-70-g380bce1

by NIIBE Yutaka cvs at cvs.gnupg.org
Tue Nov 7 03:03:05 CET 2017


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  380bce13d94ff03c96e39ac1d834f382c5c730a1 (commit)
      from  42308224d1fce64c666aed2be5eb4ef42e8aced4 (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 380bce13d94ff03c96e39ac1d834f382c5c730a1
Author: NIIBE Yutaka <gniibe at fsij.org>
Date:   Tue Nov 7 10:49:36 2017 +0900

    agent: Use clock or clock_gettime for calibration.
    
    * agent/protect.c (calibrate_get_time): Use clock or clock_gettime.
    
    --
    
    For calibration, clock(3) is better than times(3) among UNIXen.
    Tested on NetBSD 7.1 and FreeBSD 11.1, using QEMU.
    
    Thanks to Damien Goutte-Gattat for the information of use of
    CLOCKS_PER_SEC;  The old code with times(3) is not 100% correct,
    in terms of POSIX.  It should have used sysconf (_SC_CLK_TCK) instead
    of CLOCKS_PER_SEC.  CLOCKS_PER_SEC is specifically for clock(3).
    
    GnuPG-bug-id: 3056, 3276, 3472
    Signed-off-by: NIIBE Yutaka <gniibe at fsij.org>

diff --git a/agent/protect.c b/agent/protect.c
index fe44f18..90690d9 100644
--- a/agent/protect.c
+++ b/agent/protect.c
@@ -23,6 +23,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <time.h>
 #include <ctype.h>
 #include <assert.h>
 #include <unistd.h>
@@ -104,11 +105,14 @@ calibrate_get_time (struct calibrate_time_s *data)
                    &data->creation_time, &data->exit_time,
                    &data->kernel_time, &data->user_time);
 # endif
-#else
-  struct tms tmp;
+#elif defined (CLOCK_THREAD_CPUTIME_ID)
+  struct timespec tmp;
 
-  times (&tmp);
-  data->ticks = tmp.tms_utime;
+  clock_gettime (CLOCK_THREAD_CPUTIME_ID, &tmp);
+  data->ticks = (clock_t)(((unsigned long long)tmp.tv_sec * 1000000000 +
+                           tmp.tv_nsec) * CLOCKS_PER_SEC / 1000000000);
+#else
+  data->ticks = clock ();
 #endif
 }
 
@@ -135,7 +139,7 @@ calibrate_elapsed_time (struct calibrate_time_s *starttime)
   }
 #else
   return (unsigned long)((((double) (stoptime.ticks - starttime->ticks))
-                          /CLOCKS_PER_SEC)*10000000);
+                          /CLOCKS_PER_SEC)*1000);
 #endif
 }
 
diff --git a/agent/t-protect.c b/agent/t-protect.c
index 1d3c8ec..92d312c 100644
--- a/agent/t-protect.c
+++ b/agent/t-protect.c
@@ -322,9 +322,9 @@ test_agent_protect_shared_secret (void)
 int
 main (int argc, char **argv)
 {
-  (void)argc;
   (void)argv;
 
+  opt.verbose = argc - 1;       /* We can do "./t-protect -v -v" */
   gcry_control (GCRYCTL_DISABLE_SECMEM);
 
   test_agent_protect ();

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

Summary of changes:
 agent/protect.c   | 14 +++++++++-----
 agent/t-protect.c |  2 +-
 2 files changed, 10 insertions(+), 6 deletions(-)


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




More information about the Gnupg-commits mailing list