From b55c13dec24ef2443f4c94e43e01137047254904 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sat, 28 Aug 2021 18:09:22 +0200 Subject: [PATCH] Use operators for min/max Turns out AVR doesn't have __builtin_min/max --- src/cmath.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cmath.h b/src/cmath.h index ffd6128..53e5d18 100644 --- a/src/cmath.h +++ b/src/cmath.h @@ -9,19 +9,19 @@ // AVR libc doesn't support cmath #include -// Use builtin functions for min/max/abs template static inline const T min(T a, T b) { - return __builtin_min((a, b)); + return a <= b ? a : b; } template static inline const T max(T a, T b) { - return __builtin_max((a, b)); + return a > b ? a : b; } template static inline const T abs(T n) { + // Use builtin function when available return __builtin_abs((n)); }