AP_HAL_Macros.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #pragma once
  2. #include <AP_HAL/AP_HAL_Boards.h>
  3. /*
  4. macros to allow code to build on multiple platforms more easily
  5. */
  6. #if CONFIG_HAL_BOARD == HAL_BOARD_SITL || CONFIG_HAL_BOARD == HAL_BOARD_LINUX
  7. /*
  8. allow double maths on Linux and SITL to avoid problems with system headers
  9. */
  10. #define ALLOW_DOUBLE_MATH_FUNCTIONS
  11. #endif
  12. #if !defined(ALLOW_DOUBLE_MATH_FUNCTIONS)
  13. /* give warnings if we use double precision maths functions without
  14. specifying ALLOW_DOUBLE_TRIG_FUNCTIONS. Code should use the
  15. equivalent f function instead (eg. use cosf() instead of
  16. cos()). Individual cpp files that really do need double precision
  17. should define ALLOW_DOUBLE_TRIG_FUNCTIONS before including
  18. AP_Math.h
  19. */
  20. #define sin(x) DO_NOT_USE_DOUBLE_MATHS()
  21. #define cos(x) DO_NOT_USE_DOUBLE_MATHS()
  22. #define tan(x) DO_NOT_USE_DOUBLE_MATHS()
  23. #define acos(x) DO_NOT_USE_DOUBLE_MATHS()
  24. #define asin(x) DO_NOT_USE_DOUBLE_MATHS()
  25. #define atan(x) DO_NOT_USE_DOUBLE_MATHS()
  26. #define atan2(x,y) DO_NOT_USE_DOUBLE_MATHS()
  27. #define exp(x) DO_NOT_USE_DOUBLE_MATHS()
  28. #define pow(x,y) DO_NOT_USE_DOUBLE_MATHS()
  29. #define sqrt(x) DO_NOT_USE_DOUBLE_MATHS()
  30. #define log2(x) DO_NOT_USE_DOUBLE_MATHS()
  31. #define log10(x) DO_NOT_USE_DOUBLE_MATHS()
  32. #define ceil(x) DO_NOT_USE_DOUBLE_MATHS()
  33. #define floor(x) DO_NOT_USE_DOUBLE_MATHS()
  34. #define round(x) DO_NOT_USE_DOUBLE_MATHS()
  35. #define fmax(x,y) DO_NOT_USE_DOUBLE_MATHS()
  36. #if !HAL_WITH_UAVCAN
  37. // we should do log() and fabs() as well, but can't because of a conflict in uavcan
  38. #define log(x) DO_NOT_USE_DOUBLE_MATHS()
  39. #define fabs(x) DO_NOT_USE_DOUBLE_MATHS()
  40. #endif
  41. #endif