New header for saturating arithmetic.
[openvswitch] / lib / dhcp-client.c
index 9df0c6c6c0bbb3b2a912c39e7dc913e9228daa48..c05b6149364329740211a915ee80d1ae2c78a0d3 100644 (file)
@@ -51,6 +51,7 @@
 #include "netdev.h"
 #include "ofp-print.h"
 #include "poll-loop.h"
+#include "sat-math.h"
 #include "timeval.h"
 
 #define THIS_MODULE VLM_dhcp_client
@@ -140,9 +141,6 @@ static unsigned int calc_t2(unsigned int lease);
 static unsigned int calc_t1(unsigned int lease, unsigned int t2);
 
 static unsigned int clamp(unsigned int x, unsigned int min, unsigned int max);
-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);
 
 /* Creates a new DHCP client to configure the network device 'netdev_name'
  * (e.g. "eth0").
@@ -1013,25 +1011,6 @@ fuzz(unsigned int x, int max_fuzz)
     return fuzz >= 0 ? (y >= x ? y : UINT_MAX) : (y <= x ? y : 0);
 }
 
-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 unsigned int
 clamp(unsigned int x, unsigned int min, unsigned int max)
 {