Add src/cmath.h for <math.h> portability between platforms

pull/47/head
Yuri D'Elia 2021-07-05 18:13:27 +02:00
parent de88ed4c6b
commit 7d2329cf85
1 changed files with 17 additions and 0 deletions

17
src/cmath.h Normal file
View File

@ -0,0 +1,17 @@
// Provide an uniform interface for basic math functions between AVR libc and newer
// standards that support <cmath>
#pragma once
#ifndef __AVR__
#include <cmath>
#else
// AVR libc doesn't support cmath
#include <math.h>
// 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