New header for saturating arithmetic.
[openvswitch] / lib / rconn.c
index 6365a46b89e1eac0677b32ad1e5ffa0892837cc7..ee995e499d7ec80310687fbb12d0cd071e045582 100644 (file)
@@ -41,6 +41,7 @@
 #include "buffer.h"
 #include "poll-loop.h"
 #include "ofp-print.h"
+#include "sat-math.h"
 #include "timeval.h"
 #include "util.h"
 #include "vconn.h"
@@ -115,9 +116,6 @@ struct rconn {
     int probe_interval;         /* Secs of inactivity before sending probe. */
 };
 
-static unsigned int sat_add(unsigned int x, unsigned int y);
-static unsigned int sat_sub(unsigned int x, unsigned int y);
-static unsigned int sat_mul(unsigned int x, unsigned int y);
 static unsigned int elapsed_in_this_state(const struct rconn *);
 static unsigned int timeout(const struct rconn *);
 static bool timed_out(const struct rconn *);
@@ -745,25 +743,6 @@ state_transition(struct rconn *rc, enum state state)
     rc->state_entered = time_now();
 }
 
-static unsigned int
-sat_add(unsigned int x, unsigned int y)
-{
-    return x + y >= x ? x + y : UINT_MAX;
-}
-
-static unsigned int
-sat_sub(unsigned int x, unsigned int y)
-{
-    return x >= y ? x - y : 0;
-}
-
-static unsigned int
-sat_mul(unsigned int x, unsigned int y)
-{
-    assert(y);
-    return x <= UINT_MAX / y ? x * y : UINT_MAX;
-}
-
 static void
 question_connectivity(struct rconn *rc) 
 {