Use clock_gettime(CLOCK_MONOTONIC) and timespec everywhere
We should really be using monotonic clock in all places that
gettimeofday is used right now. Since clock_gettime() uses timespec,
let's move all code to use timespecs instead to avoid having to convert
in several places between timespec and timeval.
Actually use osmo_clock_gettime() shim everywhere to be able to control
the time everywhere from unit tests.
Change-Id: Ie265d70f8ffa7dbf7efbef6030505d9fcb5dc338
diff --git a/src/gprs_bssgp_pcu.h b/src/gprs_bssgp_pcu.h
index f98e719..2ceef60 100644
--- a/src/gprs_bssgp_pcu.h
+++ b/src/gprs_bssgp_pcu.h
@@ -37,6 +37,8 @@
}
#include <gprs_debug.h>
+#include <time.h>
+
#define QOS_PROFILE 4
#define BSSGP_HDR_LEN 53
#define NS_HDR_LEN 4
@@ -57,7 +59,7 @@
int bvc_unblocked;
/* Flow control */
- struct timeval queue_delay_sum;
+ struct timespec queue_delay_sum;
unsigned queue_delay_count;
uint8_t fc_tag;
unsigned queue_frames_sent;
@@ -87,8 +89,8 @@
struct bssgp_bvc_ctx *gprs_bssgp_pcu_current_bctx(void);
-void gprs_bssgp_update_queue_delay(const struct timeval *tv_recv,
- const struct timeval *tv_now);
+void gprs_bssgp_update_queue_delay(const struct timespec *tv_recv,
+ const struct timespec *tv_now);
void gprs_bssgp_update_frames_sent();
void gprs_bssgp_update_bytes_received(unsigned bytes_recv, unsigned frames_recv);