test-math-cxx11.cc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /* Test C99 math functions are available in C++11 without _GNU_SOURCE.
  2. Copyright (C) 2017-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 _GNU_SOURCE
  16. #undef _DEFAULT_SOURCE
  17. #undef _XOPEN_SOURCE
  18. #undef _POSIX_SOURCE
  19. #undef _POSIX_C_SOURCE
  20. // __STRICT_ANSI__ gets defined by -std=c++11 in CFLAGS
  21. #include <math.h>
  22. #include <stdio.h>
  23. static int
  24. do_test (void)
  25. {
  26. #ifdef _GNU_SOURCE
  27. printf ("FAIL: _GNU_SOURCE is defined.\n");
  28. return 1;
  29. #endif
  30. #if __cplusplus >= 201103L
  31. /* Verify that C11 math functions and types are defined for C++11,
  32. without _GNU_SOURCE being defined. [BZ #21326] */
  33. (void) FP_INFINITE;
  34. (void) FP_NAN;
  35. (void) FP_NORMAL;
  36. (void) FP_SUBNORMAL;
  37. (void) FP_ZERO;
  38. double_t d = 1.0;
  39. (void) d;
  40. float_t f = 1.0f;
  41. (void) f;
  42. (void) acosh;
  43. (void) acoshf;
  44. (void) acoshl;
  45. (void) asinh;
  46. (void) asinhf;
  47. (void) asinhl;
  48. (void) atanh;
  49. (void) atanhf;
  50. (void) atanhl;
  51. (void) cbrt;
  52. (void) cbrtf;
  53. (void) cbrtl;
  54. (void) copysign;
  55. (void) copysignf;
  56. (void) copysignl;
  57. (void) erf;
  58. (void) erff;
  59. (void) erfl;
  60. (void) erfc;
  61. (void) erfcf;
  62. (void) erfcl;
  63. (void) exp2;
  64. (void) exp2f;
  65. (void) exp2l;
  66. (void) expm1;
  67. (void) expm1f;
  68. (void) expm1l;
  69. (void) fdim;
  70. (void) fdimf;
  71. (void) fdiml;
  72. (void) fma;
  73. (void) fmaf;
  74. (void) fmal;
  75. (void) fmax;
  76. (void) fmaxf;
  77. (void) fmaxl;
  78. (void) fmin;
  79. (void) fminf;
  80. (void) fminl;
  81. (void) hypot;
  82. (void) hypotf;
  83. (void) hypotl;
  84. (void) ilogb;
  85. (void) ilogbf;
  86. (void) ilogbl;
  87. (void) lgamma;
  88. (void) lgammaf;
  89. (void) lgammal;
  90. (void) llrint;
  91. (void) llrintf;
  92. (void) llrintl;
  93. (void) llround;
  94. (void) llroundf;
  95. (void) llroundl;
  96. (void) log1p;
  97. (void) log1pf;
  98. (void) log1pl;
  99. (void) log2;
  100. (void) log2f;
  101. (void) log2l;
  102. (void) logb;
  103. (void) logbf;
  104. (void) logbl;
  105. (void) lrint;
  106. (void) lrintf;
  107. (void) lrintl;
  108. (void) lround;
  109. (void) lroundf;
  110. (void) lroundl;
  111. (void) nan;
  112. (void) nanf;
  113. (void) nanl;
  114. (void) nearbyint;
  115. (void) nearbyintf;
  116. (void) nearbyintl;
  117. (void) nextafter;
  118. (void) nextafterf;
  119. (void) nextafterl;
  120. (void) nexttoward;
  121. (void) nexttowardf;
  122. (void) nexttowardl;
  123. (void) remainder;
  124. (void) remainderf;
  125. (void) remainderl;
  126. (void) remquo;
  127. (void) remquof;
  128. (void) remquol;
  129. (void) rint;
  130. (void) rintf;
  131. (void) rintl;
  132. (void) round;
  133. (void) roundf;
  134. (void) roundl;
  135. (void) scalbln;
  136. (void) scalblnf;
  137. (void) scalblnl;
  138. (void) scalbn;
  139. (void) scalbnf;
  140. (void) scalbnl;
  141. (void) tgamma;
  142. (void) tgammaf;
  143. (void) tgammal;
  144. (void) trunc;
  145. (void) truncf;
  146. (void) truncl;
  147. printf ("PASS: C11 math functions present in C++11 without _GNU_SOURCE.\n");
  148. #else
  149. printf ("UNSUPPORTED: C++11 not enabled.\n");
  150. #endif
  151. return 0;
  152. }
  153. #include <support/test-driver.c>