20010114-2.c 707 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (C) 2007
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. /*
  8. * This file is originally a part of the GCC testsuite.
  9. */
  10. #include <common.h>
  11. #include <post.h>
  12. GNU_FPOST_ATTR
  13. #if CONFIG_POST & CONFIG_SYS_POST_FPU
  14. static float rintf (float x)
  15. {
  16. volatile float TWO23 = 8388608.0;
  17. if (__builtin_fabs (x) < TWO23)
  18. {
  19. if (x > 0.0)
  20. {
  21. x += TWO23;
  22. x -= TWO23;
  23. }
  24. else if (x < 0.0)
  25. {
  26. x = TWO23 - x;
  27. x = -(x - TWO23);
  28. }
  29. }
  30. return x;
  31. }
  32. int fpu_post_test_math2 (void)
  33. {
  34. if (rintf (-1.5) != -2.0) {
  35. post_log ("Error in FPU math2 test\n");
  36. return -1;
  37. }
  38. return 0;
  39. }
  40. #endif /* CONFIG_POST & CONFIG_SYS_POST_FPU */