static inline uint16_t htons(uint16_t val) __attribute__ ((alias ("byte_swap_16")));
-/* MIN and MAX */
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-#define MAX(a, b) (((a) > (b)) ? (a) : (b))
+/* Min, Max and Abs */
+static inline uint32_t abs(int32_t val)
+{
+ return val < 0 ? -val : val;
+}
+
+static inline uint32_t min(uint32_t a, uint32_t b)
+{
+ return a < b ? a : b;
+}
+
+static inline uint32_t max(uint32_t a, uint32_t b)
+{
+ return a > b ? a : b;
+}
+
+static inline uint32_t constrain(int32_t val, int32_t min, int32_t max)
+{
+ return val < min ? min : val > max ? max : val;
+}
#endif /* LIB_UTILS_H */