test-signgam-main.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* Test lgamma functions do not set signgam 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. #define INITVAL ((TYPE) -1 / 3)
  21. #if DO_INIT
  22. TYPE signgam = INITVAL;
  23. #else
  24. TYPE signgam;
  25. #endif
  26. #define RUN_TESTS(FUNC, TYPE) \
  27. do \
  28. { \
  29. volatile TYPE a, b, c __attribute__ ((unused)); \
  30. a = 0.5; \
  31. b = -0.5; \
  32. signgam = INITVAL; \
  33. c = FUNC (a); \
  34. if (signgam == INITVAL) \
  35. puts ("PASS: " #FUNC " (0.5) setting signgam"); \
  36. else \
  37. { \
  38. puts ("FAIL: " #FUNC " (0.5) setting signgam"); \
  39. result = 1; \
  40. } \
  41. signgam = INITVAL; \
  42. c = FUNC (b); \
  43. if (signgam == INITVAL) \
  44. puts ("PASS: " #FUNC " (-0.5) setting signgam"); \
  45. else \
  46. { \
  47. puts ("FAIL: " #FUNC " (-0.5) setting signgam"); \
  48. result = 1; \
  49. } \
  50. } \
  51. while (0)
  52. int
  53. main (void)
  54. {
  55. int result = 0;
  56. RUN_TESTS (lgammaf, float);
  57. RUN_TESTS (lgamma, double);
  58. RUN_TESTS (lgammal, long double);
  59. return result;
  60. }