[REFACTOR] Refactor getting app start time
authorDmitry Bogatov <d.bogatov@samsung.com>
Wed, 6 Nov 2013 07:49:57 +0000 (11:49 +0400)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Thu, 7 Nov 2013 05:58:43 +0000 (05:58 +0000)
Change-Id: I2e3099a700d5281e1517b28f0923cd4c533f5864
Signed-off-by: Dmitry Bogatov <d.bogatov@samsung.com>
helper/libdaprobe.c

index dc6435b..b501bb8 100755 (executable)
@@ -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) {