test-signgam-finite-c99.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* Test lgamma functions do not set signgam for -ffinite-math-only for ISO C.
  2. Copyright (C) 2015-2016 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. #undef _Mlong_double_
  19. #define _ISOMAC
  20. #include <math.h>
  21. #include <stdio.h>
  22. int signgam;
  23. #define RUN_TESTS(FUNC, TYPE) \
  24. do \
  25. { \
  26. volatile TYPE a, b, c __attribute__ ((unused)); \
  27. a = 0.5; \
  28. b = -0.5; \
  29. signgam = 123; \
  30. c = FUNC (a); \
  31. if (signgam == 123) \
  32. puts ("PASS: " #FUNC " (0.5) setting signgam"); \
  33. else \
  34. { \
  35. puts ("FAIL: " #FUNC " (0.5) setting signgam"); \
  36. result = 1; \
  37. } \
  38. signgam = 123; \
  39. c = FUNC (b); \
  40. if (signgam == 123) \
  41. puts ("PASS: " #FUNC " (-0.5) setting signgam"); \
  42. else \
  43. { \
  44. puts ("FAIL: " #FUNC " (-0.5) setting signgam"); \
  45. result = 1; \
  46. } \
  47. } \
  48. while (0)
  49. int
  50. main (void)
  51. {
  52. int result = 0;
  53. RUN_TESTS (lgammaf, float);
  54. RUN_TESTS (lgamma, double);
  55. #ifndef NO_LONG_DOUBLE
  56. RUN_TESTS (lgammal, long double);
  57. #endif
  58. return result;
  59. }