X-Git-Url: http://git.meshlink.io/?p=utcp;a=blobdiff_plain;f=utcp.c;h=0b36de15263b8b005c0625f866e901054432b5ba;hp=cc17b0f744b0f4b63109daed01b55996f50f7613;hb=bf55733700d946f678947a6caaa782b56669a3f1;hpb=723d8c8b2d96834135f00c0ac4147282e1f0cc2c diff --git a/utcp.c b/utcp.c index cc17b0f..0b36de1 100644 --- a/utcp.c +++ b/utcp.c @@ -73,7 +73,7 @@ static bool timespec_isset(const struct timespec *a) { 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; @@ -2056,7 +2056,7 @@ struct utcp *utcp_init(utcp_accept_t accept, utcp_pre_accept_t pre_accept, utcp_ 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; @@ -2331,3 +2331,7 @@ void utcp_offline(struct utcp *utcp, bool offline) { utcp->rto = START_RTO; } } + +void utcp_set_clock_granularity(long granularity) { + CLOCK_GRANULARITY = granularity; +}