summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--utils.c10
-rw-r--r--utils.h1
2 files changed, 11 insertions, 0 deletions
diff --git a/utils.c b/utils.c
index ce2f2a9..38b5803 100644
--- a/utils.c
+++ b/utils.c
@@ -43,6 +43,9 @@
#define LOG_TAG "QTI PowerHAL"
#include <log/log.h>
+#define USINSEC 1000000L
+#define NSINUS 1000L
+
#define SOC_ID_0 "/sys/devices/soc0/soc_id"
#define SOC_ID_1 "/sys/devices/system/soc/soc0/id"
@@ -359,3 +362,10 @@ int get_soc_id(void) {
close(fd);
return soc_id;
}
+
+long long calc_timespan_us(struct timespec start, struct timespec end) {
+ long long diff_in_us = 0;
+ diff_in_us += (end.tv_sec - start.tv_sec) * USINSEC;
+ diff_in_us += (end.tv_nsec - start.tv_nsec) / NSINUS;
+ return diff_in_us;
+}
diff --git a/utils.h b/utils.h
index b4aa2a5..2c46a20 100644
--- a/utils.h
+++ b/utils.h
@@ -44,4 +44,5 @@ void interaction(int duration, int num_args, int opt_list[]);
int interaction_with_handle(int lock_handle, int duration, int num_args, int opt_list[]);
int perf_hint_enable(int hint_id, int duration);
+long long calc_timespan_us(struct timespec start, struct timespec end);
int get_soc_id(void);