Commit f6293140 by Juliusz Chroboczek

Make roughly work on signed integers.

This is needed for the stability aware code.
1 parent ab6a6bd1
......@@ -36,10 +36,15 @@ THE SOFTWARE.
#include "babeld.h"
#include "util.h"
unsigned
roughly(unsigned value)
int
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
......
......@@ -66,7 +66,7 @@ seqno_plus(unsigned short s, int plus)
return ((s + plus) & 0xFFFF);
}
unsigned roughly(unsigned value);
int roughly(int value);
void timeval_minus(struct timeval *d,
const struct timeval *s1, const struct timeval *s2);
unsigned timeval_minus_msec(const struct timeval *s1, const struct timeval *s2)
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!