test-signgam-finite-c99.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* Test lgamma functions do not set signgam for -ffinite-math-only for ISO C.
  2. Copyright (C) 2015-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #undef _LIBC
  16. #undef __LIBC_INTERNAL_MATH_INLINES
  17. #undef _GNU_SOURCE
  18. #include <math.h>
  19. #include <stdio.h>
  20. int signgam;
  21. #define RUN_TESTS(FUNC, TYPE) \
  22. do \
  23. { \
  24. volatile TYPE a, b, c __attribute__ ((unused)); \
  25. a = 0.5; \
  26. b = -0.5; \
  27. signgam = 123; \
  28. c = FUNC (a); \
  29. if (signgam == 123) \
  30. puts ("PASS: " #FUNC " (0.5) setting signgam"); \
  31. else \
  32. { \
  33. puts ("FAIL: " #FUNC " (0.5) setting signgam"); \
  34. result = 1; \
  35. } \
  36. signgam = 123; \
  37. c = FUNC (b); \
  38. if (signgam == 123) \
  39. puts ("PASS: " #FUNC " (-0.5) setting signgam"); \
  40. else \
  41. { \
  42. puts ("FAIL: " #FUNC " (-0.5) setting signgam"); \
  43. result = 1; \
  44. } \
  45. } \
  46. while (0)
  47. int
  48. main (void)
  49. {
  50. int result = 0;
  51. RUN_TESTS (lgammaf, float);
  52. RUN_TESTS (lgamma, double);
  53. RUN_TESTS (lgammal, long double);
  54. return result;
  55. }