[Announce] Libgcrypt 1.3.2 (devel) released

Werner Koch wk at gnupg.org
Mon Dec 3 12:44:57 CET 2007


On Mon,  3 Dec 2007 12:13, simon at josefsson.org said:

> As far as I recall, earlier version used to say '0ms' instead, but I may
> be mistaken.  The difference may be because of wine changes too.
> Anyway, not a big deal.

Well, I fixed the timing code and they give proper results on XP.  Thus
I conclude that this is a Wine problem.  Find below the relevant code.



Shalom-Salam,

   Werner


static void
start_timer (void)
{
#ifdef _WIN32
  GetProcessTimes (GetCurrentProcess (),
                   &started_at.creation_time, &started_at.exit_time,
                   &started_at.kernel_time, &started_at.user_time);
  stopped_at = started_at;
#else
  struct tms tmp;

  times (&tmp);
  started_at = stopped_at = tmp.tms_utime;
#endif
}

static void
stop_timer (void)
{
#ifdef _WIN32
  GetProcessTimes (GetCurrentProcess (),
                   &stopped_at.creation_time, &stopped_at.exit_time,
                   &stopped_at.kernel_time, &stopped_at.user_time);
#else
  struct tms tmp;

  times (&tmp);
  stopped_at = tmp.tms_utime;
#endif
}

static const char *
elapsed_time (void)
{
  static char buf[50];
#if _WIN32
  unsigned long long t1, t2, t;

  t1 = (((unsigned long long)started_at.kernel_time.dwHighDateTime << 32)
        + started_at.kernel_time.dwLowDateTime);
  t1 += (((unsigned long long)started_at.user_time.dwHighDateTime << 32)
        + started_at.user_time.dwLowDateTime);
  t2 = (((unsigned long long)stopped_at.kernel_time.dwHighDateTime << 32)
        + stopped_at.kernel_time.dwLowDateTime);
  t2 += (((unsigned long long)stopped_at.user_time.dwHighDateTime << 32)
        + stopped_at.user_time.dwLowDateTime);
  t = (t2 - t1)/10000;
  snprintf (buf, sizeof buf, "%5lums", (unsigned long)t );
#else
  snprintf (buf, sizeof buf, "%5.0fms",
            (((double) (stopped_at - started_at))/CLOCKS_PER_SEC)*10000000);
#endif
  return buf;
}

-- 
Die Gedanken sind frei.  Auschnahme regelt ein Bundeschgesetz.




More information about the Gcrypt-devel mailing list