This overrides the value gotten from clock_getres(), and is intended for
use by an application that knows it might not call utcp_timeout()
exactly on time.
return a->tv_sec;
}
-static long CLOCK_GRANULARITY;
+static long CLOCK_GRANULARITY; // usec
static inline size_t min(size_t a, size_t b) {
return a < b ? a : b;
if(!CLOCK_GRANULARITY) {
struct timespec res;
clock_getres(UTCP_CLOCK, &res);
- CLOCK_GRANULARITY = res.tv_sec * NSEC_PER_SEC + res.tv_nsec;
+ CLOCK_GRANULARITY = res.tv_sec * USEC_PER_SEC + res.tv_nsec / 1000;
}
utcp->accept = accept;
utcp->rto = START_RTO;
}
}
+
+void utcp_set_clock_granularity(long granularity) {
+ CLOCK_GRANULARITY = granularity;
+}
extern void utcp_expect_data(struct utcp_connection *connection, bool expect);
+// Completely global options
+
+extern void utcp_set_clock_granularity(long granularity);
+
#endif