Commit f6293140 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Make roughly work on signed integers.

This is needed for the stability aware code.
parent ab6a6bd1
...@@ -36,10 +36,15 @@ THE SOFTWARE. ...@@ -36,10 +36,15 @@ THE SOFTWARE.
#include "babeld.h" #include "babeld.h"
#include "util.h" #include "util.h"
unsigned int
roughly(unsigned value) roughly(int value)
{ {
return value * 3 / 4 + random() % (value / 2); if(value < 0)
return -roughly(-value);
else if(value <= 1)
return value;
else
return value * 3 / 4 + random() % (value / 2);
} }
void void
......
...@@ -66,7 +66,7 @@ seqno_plus(unsigned short s, int plus) ...@@ -66,7 +66,7 @@ seqno_plus(unsigned short s, int plus)
return ((s + plus) & 0xFFFF); return ((s + plus) & 0xFFFF);
} }
unsigned roughly(unsigned value); int roughly(int value);
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);
unsigned timeval_minus_msec(const struct timeval *s1, const struct timeval *s2) unsigned timeval_minus_msec(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