X-Git-Url: http://git.cascardo.eti.br/?a=blobdiff_plain;f=lib%2Fsat-math.h;h=beeff8b2b42902902f53a9a576e52e17c646e28b;hb=8c7be52d10a1e9a4745249a4a94540df13d847a3;hp=3d1c50bdccc09ce9d919c0fd0c6ab72e8d353e3f;hpb=d668c4a94192269235510fa7d23e324ed1155a78;p=cascardo%2Fovs.git diff --git a/lib/sat-math.h b/lib/sat-math.h index 3d1c50bdc..beeff8b2b 100644 --- a/lib/sat-math.h +++ b/lib/sat-math.h @@ -18,6 +18,7 @@ #define SAT_MATH_H 1 #include +#include "openvswitch/util.h" /* Saturating addition: overflow yields UINT_MAX. */ static inline unsigned int @@ -33,15 +34,10 @@ sat_sub(unsigned int x, unsigned int y) return x >= y ? x - y : 0; } -/* Saturating multiplication of "unsigned int"s: overflow yields UINT_MAX. */ -#define SAT_MUL(X, Y) \ - ((Y) == 0 ? 0 \ - : (X) <= UINT_MAX / (Y) ? (unsigned int) (X) * (unsigned int) (Y) \ - : UINT_MAX) static inline unsigned int sat_mul(unsigned int x, unsigned int y) { - return SAT_MUL(x, y); + return OVS_SAT_MUL(x, y); } #endif /* sat-math.h */