aboutsummaryrefslogtreecommitdiffstats
path: root/src/gprs_codel.h
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2020-03-11 14:04:52 +0100
committerlaforge <laforge@osmocom.org>2020-03-16 10:31:56 +0000
commit1de687381024cdc58633563e1ee8dddf6300610d (patch)
tree12f5df6230a067176354930447fa9d9d97ad5bee /src/gprs_codel.h
parent29aeb901e47b39e8e5629eb5108b3f846393b745 (diff)
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
Diffstat (limited to 'src/gprs_codel.h')
-rw-r--r--src/gprs_codel.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/gprs_codel.h b/src/gprs_codel.h
index fb744232..3ad7efce 100644
--- a/src/gprs_codel.h
+++ b/src/gprs_codel.h
@@ -27,7 +27,7 @@
#pragma once
-#include <sys/time.h>
+#include <time.h>
/* Spec default values */
#define GPRS_CODEL_DEFAULT_INTERVAL_MS 100
@@ -40,10 +40,10 @@ extern "C" {
struct gprs_codel {
int dropping;
unsigned count;
- struct timeval first_above_time;
- struct timeval drop_next;
- struct timeval target;
- struct timeval interval;
+ struct timespec first_above_time;
+ struct timespec drop_next;
+ struct timespec target;
+ struct timespec interval;
unsigned maxpacket;
};
@@ -66,8 +66,8 @@ struct gprs_codel {
*
* \return != 0 if the packet should be dropped, 0 otherwise
*/
-int gprs_codel_control(struct gprs_codel *state, const struct timeval *recv,
- const struct timeval *now, int bytes);
+int gprs_codel_control(struct gprs_codel *state, const struct timespec *recv,
+ const struct timespec *now, int bytes);
/*!
* \brief Initialise CoDel state