test-signgam-main.c 1.9 KB

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