Commit 067cd537 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Implement roughly.

parent 42ea5c40
...@@ -63,6 +63,12 @@ seqno_plus(unsigned short s, int plus) ...@@ -63,6 +63,12 @@ seqno_plus(unsigned short s, int plus)
return ((s + plus) & 0xFFFF); return ((s + plus) & 0xFFFF);
} }
int
roughly(int value)
{
return value * 3 / 4 + random() % (value / 2);
}
/* Like gettimeofday, but should return monotonic time. If POSIX clocks /* Like gettimeofday, but should return monotonic time. If POSIX clocks
are not available, falls back to gettimeofday. */ are not available, falls back to gettimeofday. */
int int
......
...@@ -26,6 +26,7 @@ int seqno_minus(unsigned short s1, unsigned short s2) ...@@ -26,6 +26,7 @@ int seqno_minus(unsigned short s1, unsigned short s2)
ATTRIBUTE ((const)); ATTRIBUTE ((const));
unsigned short seqno_plus(unsigned short s, int plus) unsigned short seqno_plus(unsigned short s, int plus)
ATTRIBUTE ((const)); ATTRIBUTE ((const));
int roughly(int value);
int gettime(struct timeval *tv); int gettime(struct timeval *tv);
void timeval_minus(struct timeval *d, void timeval_minus(struct timeval *d,
const struct timeval *s1, const struct timeval *s2); const struct timeval *s1, const struct timeval *s2);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment