[4/5] malloc: Use hp-timing on libmemusage
Checks
Context |
Check |
Description |
dj/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
Commit Message
Instead of reimplemeting on GETTIME macro.
---
malloc/memusage.c | 15 ++++++++++++---
sysdeps/generic/memusage.h | 12 ------------
sysdeps/i386/i686/memusage.h | 1 -
sysdeps/ia64/memusage.h | 7 -------
sysdeps/x86_64/memusage.h | 1 -
5 files changed, 12 insertions(+), 24 deletions(-)
@@ -35,6 +35,7 @@
#include <stdatomic.h>
#include <memusage.h>
+#include <hp-timing.h>
/* Pointer to the real functions. These are determined used `dlsym'
when really needed. */
@@ -115,6 +116,14 @@ static struct entry buffer[2 * DEFAULT_BUFFER_SIZE];
static _Atomic uint32_t buffer_cnt;
static struct entry first;
+static void
+gettime (struct entry *e)
+{
+ hp_timing_t now;
+ HP_TIMING_NOW (now);
+ e->time_low = now & 0xffffffff;
+ e->time_high = now >> 32;
+}
/* Update the global data after a successful function call. */
static void
@@ -178,7 +187,7 @@ update_data (struct header *result, size_t len, size_t old_len)
buffer[idx].heap = current_heap;
buffer[idx].stack = current_stack;
- GETTIME (buffer[idx].time_low, buffer[idx].time_high);
+ gettime (&buffer[idx]);
/* Write out buffer if it is full. */
if (idx + 1 == buffer_size)
@@ -268,7 +277,7 @@ me (void)
/* Write the first entry. */
first.heap = 0;
first.stack = 0;
- GETTIME (first.time_low, first.time_high);
+ gettime (&first);
/* Write it two times since we need the starting and end time. */
write (fd, &first, sizeof (first));
write (fd, &first, sizeof (first));
@@ -819,7 +828,7 @@ dest (void)
stack. */
first.heap = peak_heap;
first.stack = peak_stack;
- GETTIME (first.time_low, first.time_high);
+ gettime (&first);
write (fd, &first, sizeof (struct entry));
/* Close the file. */
@@ -23,15 +23,3 @@
# warning "GETSP is not defined for this architecture."
# define GETSP 0
#endif
-
-#ifndef GETTIME
-# define GETTIME(low,high) \
- { \
- struct __timespec64 now; \
- uint64_t usecs; \
- __clock_gettime64 (CLOCK_REALTIME, &now); \
- usecs = (uint64_t)now.tv_nsec / 1000 + (uint64_t)now.tv_sec * 1000000; \
- low = usecs & 0xffffffff; \
- high = usecs >> 32; \
- }
-#endif
@@ -16,6 +16,5 @@
<https://www.gnu.org/licenses/>. */
#define GETSP() ({ register uintptr_t stack_ptr asm ("esp"); stack_ptr; })
-#define GETTIME(low,high) asm ("rdtsc" : "=a" (low), "=d" (high))
#include <sysdeps/generic/memusage.h>
@@ -18,12 +18,5 @@
#include <hp-timing.h>
#define GETSP() ({ register uintptr_t stack_ptr asm ("%r12"); stack_ptr; })
-#define GETTIME(low, high) \
- { \
- hp_timing_t __now; \
- HP_TIMING_NOW (__now); \
- low = __now & 0xffffffff; \
- high = __now >> 32; \
- }
#include <sysdeps/generic/memusage.h>
@@ -16,6 +16,5 @@
<https://www.gnu.org/licenses/>. */
#define GETSP() ({ register uintptr_t stack_ptr asm ("rsp"); stack_ptr; })
-#define GETTIME(low,high) asm ("rdtsc" : "=a" (low), "=d" (high))
#include <sysdeps/generic/memusage.h>