From 7d2329cf8547fc76e428cf37841e411ee87b2f1a Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Mon, 5 Jul 2021 18:13:27 +0200 Subject: [PATCH] Add src/cmath.h for portability between platforms --- src/cmath.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/cmath.h diff --git a/src/cmath.h b/src/cmath.h new file mode 100644 index 0000000..bf876b3 --- /dev/null +++ b/src/cmath.h @@ -0,0 +1,17 @@ +// Provide an uniform interface for basic math functions between AVR libc and newer +// standards that support +#pragma once + +#ifndef __AVR__ + #include +#else + + // AVR libc doesn't support cmath + #include + + // Use builtin functions for min/max/abs + #define min(a, b) __builtin_min((a, b)) + #define max(a, b) __builtin_max((a, b)) + #define abs(n) __builtin_abs((n)) + +#endif