add osmo_gettimeofday as a shim around gettimeofday

This allows feeding a custom time for unit tests by overriding
osmo_gettimeofday.

Change-Id: Ic7a81a6eb51f27fe452962b91f2eae2070d87089
diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c
index 3ad2f29..1ee942f 100644
--- a/src/gb/gprs_bssgp.c
+++ b/src/gb/gprs_bssgp.c
@@ -603,7 +603,7 @@
 	fc->queue_depth--;
 
 	/* record the time we transmitted this PDU */
-	gettimeofday(&time_now, NULL);
+	osmo_gettimeofday(&time_now, NULL);
 	fc->time_last_pdu = time_now;
 
 	/* call the output callback for this FC instance */
@@ -688,7 +688,7 @@
 
 	/* compute number of centi-seconds that have elapsed since transmitting
 	 * the last PDU (Tc - Tp) */
-	gettimeofday(&time_now, NULL);
+	osmo_gettimeofday(&time_now, NULL);
 	timersub(&time_now, &fc->time_last_pdu, &time_diff);
 	csecs_elapsed = time_diff.tv_sec*100 + time_diff.tv_usec/10000;
 
@@ -747,7 +747,7 @@
 		return fc_enqueue(fc, msg, llc_pdu_len, priv);
 	} else {
 		/* record the time we transmitted this PDU */
-		gettimeofday(&time_now, NULL);
+		osmo_gettimeofday(&time_now, NULL);
 		fc->time_last_pdu = time_now;
 		return fc->out_cb(priv, msg, llc_pdu_len, NULL);
 	}
@@ -766,7 +766,7 @@
 	fc->bucket_leak_rate = bucket_leak_rate;
 	fc->max_queue_depth = max_queue_depth;
 	INIT_LLIST_HEAD(&fc->queue);
-	gettimeofday(&fc->time_last_pdu, NULL);
+	osmo_gettimeofday(&fc->time_last_pdu, NULL);
 }
 
 /* Initialize the Flow Control parameters for a new MS according to
diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c
index 6879c70..18845d4 100644
--- a/src/gb/gprs_ns.c
+++ b/src/gb/gprs_ns.c
@@ -556,7 +556,7 @@
 	if (osmo_timer_pending(&nsvc->timer))
 		osmo_timer_del(&nsvc->timer);
 
-	gettimeofday(&nsvc->timer_started, NULL);
+	osmo_gettimeofday(&nsvc->timer_started, NULL);
 	nsvc->timer_mode = mode;
 	osmo_timer_schedule(&nsvc->timer, seconds, 0);
 }
@@ -564,7 +564,7 @@
 static int nsvc_timer_elapsed_ms(struct gprs_nsvc *nsvc)
 {
 	struct timeval now, elapsed;
-	gettimeofday(&now, NULL);
+	osmo_gettimeofday(&now, NULL);
 	timersub(&now, &nsvc->timer_started, &elapsed);
 
 	return 1000 * elapsed.tv_sec + elapsed.tv_usec / 1000;