From 3ffb9eb0c161522b3d47f088f02d862da1d8b1ca Mon Sep 17 00:00:00 2001 From: Dmitry Bogatov Date: Wed, 6 Nov 2013 11:49:57 +0400 Subject: [PATCH] [REFACTOR] Refactor getting app start time Change-Id: I2e3099a700d5281e1517b28f0923cd4c533f5864 Signed-off-by: Dmitry Bogatov --- helper/libdaprobe.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/helper/libdaprobe.c b/helper/libdaprobe.c index dc6435b..b501bb8 100755 --- a/helper/libdaprobe.c +++ b/helper/libdaprobe.c @@ -342,11 +342,18 @@ static int init_timerfd(void) return timer; } -void __attribute__((constructor)) _init_probe() +static uint64_t get_app_start_time(void) { - struct timeval ttime; + enum {nsecs_in_sec = 1000 * 1000}; + struct timeval time; + + gettimeofday(&time, NULL); + return nsecs_in_sec * (uint64_t) time.tv_sec + time.tv_usec; +} +void __attribute__((constructor)) _init_probe() +{ probeBlockStart(); initialize_hash_table(); @@ -357,10 +364,7 @@ void __attribute__((constructor)) _init_probe() getExecutableMappingAddress(); - // get app start time - gettimeofday(&ttime, NULL); - gTraceInfo.app.startTime = (uint64_t)ttime.tv_sec * 1000 * 1000 - + ttime.tv_usec; + gTraceInfo.app.startTime = get_app_start_time(); // create socket for communication with da_daemon if (createSocket() == 0) { -- 2.7.4