flow: add miniflow_pad_from_64
[cascardo/ovs.git] / lib / sat-math.h
index ae504ba..beeff8b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008 Nicira, Inc.
+ * Copyright (c) 2008, 2012 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,8 +17,8 @@
 #ifndef SAT_MATH_H
 #define SAT_MATH_H 1
 
-#include <assert.h>
 #include <limits.h>
+#include "openvswitch/util.h"
 
 /* Saturating addition: overflow yields UINT_MAX. */
 static inline unsigned int
@@ -34,13 +34,10 @@ sat_sub(unsigned int x, unsigned int y)
     return x >= y ? x - y : 0;
 }
 
-/* Saturating multiplication: overflow yields UINT_MAX. */
 static inline unsigned int
 sat_mul(unsigned int x, unsigned int y)
 {
-    return (!y ? 0
-            : x <= UINT_MAX / y ? x * y
-            : UINT_MAX);
+    return OVS_SAT_MUL(x, y);
 }
 
 #endif /* sat-math.h */