20010114-2.c 704 B

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