/*
- * Copyright (c) 2008 Nicira Networks.
+ * 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.
#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
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 */