math-finite.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /* Entry points to finite-math-only compiler runs.
  2. Copyright (C) 2011-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. #ifndef _MATH_H
  16. # error "Never use <bits/math-finite.h> directly; include <math.h> instead."
  17. #endif
  18. #define __REDIRFROM(...) __REDIRFROM_X(__VA_ARGS__)
  19. #define __REDIRTO(...) __REDIRTO_X(__VA_ARGS__)
  20. #define __MATH_REDIRCALL_X(from, args, to) \
  21. extern _Mdouble_ __REDIRECT_NTH (from, args, to)
  22. #define __MATH_REDIRCALL(function, reentrant, args) \
  23. __MATH_REDIRCALL_X \
  24. (__REDIRFROM (function, reentrant), args, \
  25. __REDIRTO (function, reentrant))
  26. #define __MATH_REDIRCALL_2(from, reentrant, args, to) \
  27. __MATH_REDIRCALL_X \
  28. (__REDIRFROM (from, reentrant), args, \
  29. __REDIRTO (to, reentrant))
  30. #define __MATH_REDIRCALL_INTERNAL(function, reentrant, args) \
  31. __MATH_REDIRCALL_X \
  32. (__REDIRFROM (__CONCAT (__, function), \
  33. __CONCAT (reentrant, _finite)), \
  34. args, __REDIRTO (function, _r))
  35. /* acos. */
  36. __MATH_REDIRCALL (acos, , (_Mdouble_));
  37. #if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
  38. /* acosh. */
  39. __MATH_REDIRCALL (acosh, , (_Mdouble_));
  40. #endif
  41. /* asin. */
  42. __MATH_REDIRCALL (asin, , (_Mdouble_));
  43. /* atan2. */
  44. __MATH_REDIRCALL (atan2, , (_Mdouble_, _Mdouble_));
  45. #if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
  46. /* atanh. */
  47. __MATH_REDIRCALL (atanh, , (_Mdouble_));
  48. #endif
  49. /* cosh. */
  50. __MATH_REDIRCALL (cosh, , (_Mdouble_));
  51. /* exp. */
  52. __MATH_REDIRCALL (exp, , (_Mdouble_));
  53. #if __GLIBC_USE (IEC_60559_FUNCS_EXT)
  54. /* exp10. */
  55. __MATH_REDIRCALL (exp10, , (_Mdouble_));
  56. #endif
  57. #ifdef __USE_ISOC99
  58. /* exp2. */
  59. __MATH_REDIRCALL (exp2, , (_Mdouble_));
  60. #endif
  61. /* fmod. */
  62. __MATH_REDIRCALL (fmod, , (_Mdouble_, _Mdouble_));
  63. #if defined __USE_XOPEN || defined __USE_ISOC99
  64. /* hypot. */
  65. __MATH_REDIRCALL (hypot, , (_Mdouble_, _Mdouble_));
  66. #endif
  67. #if (__MATH_DECLARING_DOUBLE && (defined __USE_MISC || defined __USE_XOPEN)) \
  68. || (!__MATH_DECLARING_DOUBLE && defined __USE_MISC)
  69. /* j0. */
  70. __MATH_REDIRCALL (j0, , (_Mdouble_));
  71. /* y0. */
  72. __MATH_REDIRCALL (y0, , (_Mdouble_));
  73. /* j1. */
  74. __MATH_REDIRCALL (j1, , (_Mdouble_));
  75. /* y1. */
  76. __MATH_REDIRCALL (y1, , (_Mdouble_));
  77. /* jn. */
  78. __MATH_REDIRCALL (jn, , (int, _Mdouble_));
  79. /* yn. */
  80. __MATH_REDIRCALL (yn, , (int, _Mdouble_));
  81. #endif
  82. #ifdef __USE_MISC
  83. /* lgamma_r. */
  84. __MATH_REDIRCALL (lgamma, _r, (_Mdouble_, int *));
  85. #endif
  86. /* Redirect __lgammal_r_finite to __lgamma_r_finite when __NO_LONG_DOUBLE_MATH
  87. is set and to itself otherwise. It also redirects __lgamma_r_finite and
  88. __lgammaf_r_finite to themselves. */
  89. __MATH_REDIRCALL_INTERNAL (lgamma, _r, (_Mdouble_, int *));
  90. #if ((defined __USE_XOPEN || defined __USE_ISOC99) \
  91. && defined __extern_always_inline)
  92. /* lgamma. */
  93. __extern_always_inline _Mdouble_
  94. __NTH (__REDIRFROM (lgamma, ) (_Mdouble_ __d))
  95. {
  96. # if defined __USE_MISC || defined __USE_XOPEN
  97. return __REDIRTO (lgamma, _r) (__d, &signgam);
  98. # else
  99. int __local_signgam = 0;
  100. return __REDIRTO (lgamma, _r) (__d, &__local_signgam);
  101. # endif
  102. }
  103. #endif
  104. #if ((defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)) \
  105. && defined __extern_always_inline) && !__MATH_DECLARING_FLOATN
  106. /* gamma. */
  107. __extern_always_inline _Mdouble_
  108. __NTH (__REDIRFROM (gamma, ) (_Mdouble_ __d))
  109. {
  110. return __REDIRTO (lgamma, _r) (__d, &signgam);
  111. }
  112. #endif
  113. /* log. */
  114. __MATH_REDIRCALL (log, , (_Mdouble_));
  115. /* log10. */
  116. __MATH_REDIRCALL (log10, , (_Mdouble_));
  117. #ifdef __USE_ISOC99
  118. /* log2. */
  119. __MATH_REDIRCALL (log2, , (_Mdouble_));
  120. #endif
  121. /* pow. */
  122. __MATH_REDIRCALL (pow, , (_Mdouble_, _Mdouble_));
  123. #if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
  124. /* remainder. */
  125. __MATH_REDIRCALL (remainder, , (_Mdouble_, _Mdouble_));
  126. #endif
  127. #if ((__MATH_DECLARING_DOUBLE \
  128. && (defined __USE_MISC \
  129. || (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8))) \
  130. || (!defined __MATH_DECLARE_LDOUBLE && defined __USE_MISC)) \
  131. && !__MATH_DECLARING_FLOATN
  132. /* scalb. */
  133. __MATH_REDIRCALL (scalb, , (_Mdouble_, _Mdouble_));
  134. #endif
  135. /* sinh. */
  136. __MATH_REDIRCALL (sinh, , (_Mdouble_));
  137. /* sqrt. */
  138. __MATH_REDIRCALL (sqrt, , (_Mdouble_));
  139. #if defined __USE_ISOC99 && defined __extern_always_inline
  140. /* tgamma. */
  141. extern _Mdouble_
  142. __REDIRFROM (__gamma, _r_finite) (_Mdouble_, int *);
  143. __extern_always_inline _Mdouble_
  144. __NTH (__REDIRFROM (tgamma, ) (_Mdouble_ __d))
  145. {
  146. int __local_signgam = 0;
  147. _Mdouble_ __res = __REDIRTO (gamma, _r) (__d, &__local_signgam);
  148. return __local_signgam < 0 ? -__res : __res;
  149. }
  150. #endif
  151. #undef __REDIRFROM
  152. #undef __REDIRTO
  153. #undef __MATH_REDIRCALL
  154. #undef __MATH_REDIRCALL_2
  155. #undef __MATH_REDIRCALL_INTERNAL
  156. #undef __MATH_REDIRCALL_X