AP_HAL_Macros.h 1.6 KB

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