Page MenuHome GnuPG

D451.diff
No OneTemporary

D451.diff

diff --git a/agent/protect.c b/agent/protect.c
--- 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>
@@ -76,7 +77,7 @@
#ifdef HAVE_W32_SYSTEM
FILETIME creation_time, exit_time, kernel_time, user_time;
#else
- clock_t ticks;
+ unsigned long ms;
#endif
};
@@ -104,11 +105,24 @@
&data->creation_time, &data->exit_time,
&data->kernel_time, &data->user_time);
# endif
+#elif defined (CLOCK_THREAD_CPUTIME_ID)
+ struct timespec tmp;
+
+ clock_gettime (CLOCK_THREAD_CPUTIME_ID, &tmp);
+ /* Convert from seconds + nanoseconds to milliseconds. */
+ data->ms = (unsigned long)((tmp.tv_sec * 1000000000 + tmp.tv_nsec)
+ / 1000000.0);
#else
struct tms tmp;
+ static long ticks_per_second;
+
+ if (!ticks_per_second)
+ ticks_per_second = sysconf (_SC_CLK_TCK);
times (&tmp);
- data->ticks = tmp.tms_utime;
+ /* Convert from clock ticks to milliseconds. */
+ data->ms = (unsigned long)((tmp.tms_utime / (double)ticks_per_second)
+ * 1000);
#endif
}
@@ -134,8 +148,7 @@
return (unsigned long)((t2 - t1)/10000);
}
#else
- return (unsigned long)((((double) (stoptime.ticks - starttime->ticks))
- /CLOCKS_PER_SEC)*10000000);
+ return stoptime.ms - starttime->ms;
#endif
}

File Metadata

Mime Type
text/plain
Expires
Wed, Feb 25, 7:00 PM (15 h, 37 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
16/f9/1c57f24c0d47c78ecf85e90451e3

Event Timeline