math.h 534 B

12345678910111213141516171819202122232425262728293031
  1. /* SPDX-License-Identifier: LGPL-2.1 OR MIT */
  2. /*
  3. * math definitions for NOLIBC
  4. * Copyright (C) 2025 Thomas Weißschuh <thomas.weissschuh@linutronix.de>
  5. */
  6. /* make sure to include all global symbols */
  7. #include "nolibc.h"
  8. #ifndef _NOLIBC_SYS_MATH_H
  9. #define _NOLIBC_SYS_MATH_H
  10. static __inline__
  11. double fabs(double x)
  12. {
  13. return x >= 0 ? x : -x;
  14. }
  15. static __inline__
  16. float fabsf(float x)
  17. {
  18. return x >= 0 ? x : -x;
  19. }
  20. static __inline__
  21. long double fabsl(long double x)
  22. {
  23. return x >= 0 ? x : -x;
  24. }
  25. #endif /* _NOLIBC_SYS_MATH_H */