mathcalls.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. /* Prototype declarations for math functions; helper file for <math.h>.
  2. Copyright (C) 1996-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. /* NOTE: Because of the special way this file is used by <math.h>, this
  16. file must NOT be protected from multiple inclusion as header files
  17. usually are.
  18. This file provides prototype declarations for the math functions.
  19. Most functions are declared using the macro:
  20. __MATHCALL (NAME,[_r], (ARGS...));
  21. This means there is a function `NAME' returning `double' and a function
  22. `NAMEf' returning `float'. Each place `_Mdouble_' appears in the
  23. prototype, that is actually `double' in the prototype for `NAME' and
  24. `float' in the prototype for `NAMEf'. Reentrant variant functions are
  25. called `NAME_r' and `NAMEf_r'.
  26. Functions returning other types like `int' are declared using the macro:
  27. __MATHDECL (TYPE, NAME,[_r], (ARGS...));
  28. This is just like __MATHCALL but for a function returning `TYPE'
  29. instead of `_Mdouble_'. In all of these cases, there is still
  30. both a `NAME' and a `NAMEf' that takes `float' arguments.
  31. Note that there must be no whitespace before the argument passed for
  32. NAME, to make token pasting work with -traditional. */
  33. #ifndef _MATH_H
  34. # error "Never include <bits/mathcalls.h> directly; include <math.h> instead."
  35. #endif
  36. /* Trigonometric functions. */
  37. _Mdouble_BEGIN_NAMESPACE
  38. /* Arc cosine of X. */
  39. __MATHCALL (acos,, (_Mdouble_ __x));
  40. /* Arc sine of X. */
  41. __MATHCALL (asin,, (_Mdouble_ __x));
  42. /* Arc tangent of X. */
  43. __MATHCALL (atan,, (_Mdouble_ __x));
  44. /* Arc tangent of Y/X. */
  45. __MATHCALL (atan2,, (_Mdouble_ __y, _Mdouble_ __x));
  46. /* Cosine of X. */
  47. __MATHCALL_VEC (cos,, (_Mdouble_ __x));
  48. /* Sine of X. */
  49. __MATHCALL_VEC (sin,, (_Mdouble_ __x));
  50. /* Tangent of X. */
  51. __MATHCALL (tan,, (_Mdouble_ __x));
  52. /* Hyperbolic functions. */
  53. /* Hyperbolic cosine of X. */
  54. __MATHCALL (cosh,, (_Mdouble_ __x));
  55. /* Hyperbolic sine of X. */
  56. __MATHCALL (sinh,, (_Mdouble_ __x));
  57. /* Hyperbolic tangent of X. */
  58. __MATHCALL (tanh,, (_Mdouble_ __x));
  59. _Mdouble_END_NAMESPACE
  60. #ifdef __USE_GNU
  61. /* Cosine and sine of X. */
  62. __MATHDECL_VEC (void,sincos,,
  63. (_Mdouble_ __x, _Mdouble_ *__sinx, _Mdouble_ *__cosx));
  64. #endif
  65. #if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
  66. __BEGIN_NAMESPACE_C99
  67. /* Hyperbolic arc cosine of X. */
  68. __MATHCALL (acosh,, (_Mdouble_ __x));
  69. /* Hyperbolic arc sine of X. */
  70. __MATHCALL (asinh,, (_Mdouble_ __x));
  71. /* Hyperbolic arc tangent of X. */
  72. __MATHCALL (atanh,, (_Mdouble_ __x));
  73. __END_NAMESPACE_C99
  74. #endif
  75. /* Exponential and logarithmic functions. */
  76. _Mdouble_BEGIN_NAMESPACE
  77. /* Exponential function of X. */
  78. __MATHCALL_VEC (exp,, (_Mdouble_ __x));
  79. /* Break VALUE into a normalized fraction and an integral power of 2. */
  80. __MATHCALL (frexp,, (_Mdouble_ __x, int *__exponent));
  81. /* X times (two to the EXP power). */
  82. __MATHCALL (ldexp,, (_Mdouble_ __x, int __exponent));
  83. /* Natural logarithm of X. */
  84. __MATHCALL_VEC (log,, (_Mdouble_ __x));
  85. /* Base-ten logarithm of X. */
  86. __MATHCALL (log10,, (_Mdouble_ __x));
  87. /* Break VALUE into integral and fractional parts. */
  88. __MATHCALL (modf,, (_Mdouble_ __x, _Mdouble_ *__iptr)) __nonnull ((2));
  89. _Mdouble_END_NAMESPACE
  90. #ifdef __USE_GNU
  91. /* A function missing in all standards: compute exponent to base ten. */
  92. __MATHCALL (exp10,, (_Mdouble_ __x));
  93. /* Another name occasionally used. */
  94. __MATHCALL (pow10,, (_Mdouble_ __x));
  95. #endif
  96. #if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
  97. __BEGIN_NAMESPACE_C99
  98. /* Return exp(X) - 1. */
  99. __MATHCALL (expm1,, (_Mdouble_ __x));
  100. /* Return log(1 + X). */
  101. __MATHCALL (log1p,, (_Mdouble_ __x));
  102. /* Return the base 2 signed integral exponent of X. */
  103. __MATHCALL (logb,, (_Mdouble_ __x));
  104. __END_NAMESPACE_C99
  105. #endif
  106. #ifdef __USE_ISOC99
  107. __BEGIN_NAMESPACE_C99
  108. /* Compute base-2 exponential of X. */
  109. __MATHCALL (exp2,, (_Mdouble_ __x));
  110. /* Compute base-2 logarithm of X. */
  111. __MATHCALL (log2,, (_Mdouble_ __x));
  112. __END_NAMESPACE_C99
  113. #endif
  114. /* Power functions. */
  115. _Mdouble_BEGIN_NAMESPACE
  116. /* Return X to the Y power. */
  117. __MATHCALL_VEC (pow,, (_Mdouble_ __x, _Mdouble_ __y));
  118. /* Return the square root of X. */
  119. __MATHCALL (sqrt,, (_Mdouble_ __x));
  120. _Mdouble_END_NAMESPACE
  121. #if defined __USE_XOPEN || defined __USE_ISOC99
  122. __BEGIN_NAMESPACE_C99
  123. /* Return `sqrt(X*X + Y*Y)'. */
  124. __MATHCALL (hypot,, (_Mdouble_ __x, _Mdouble_ __y));
  125. __END_NAMESPACE_C99
  126. #endif
  127. #if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
  128. __BEGIN_NAMESPACE_C99
  129. /* Return the cube root of X. */
  130. __MATHCALL (cbrt,, (_Mdouble_ __x));
  131. __END_NAMESPACE_C99
  132. #endif
  133. /* Nearest integer, absolute value, and remainder functions. */
  134. _Mdouble_BEGIN_NAMESPACE
  135. /* Smallest integral value not less than X. */
  136. __MATHCALLX (ceil,, (_Mdouble_ __x), (__const__));
  137. /* Absolute value of X. */
  138. __MATHCALLX (fabs,, (_Mdouble_ __x), (__const__));
  139. /* Largest integer not greater than X. */
  140. __MATHCALLX (floor,, (_Mdouble_ __x), (__const__));
  141. /* Floating-point modulo remainder of X/Y. */
  142. __MATHCALL (fmod,, (_Mdouble_ __x, _Mdouble_ __y));
  143. /* Return 0 if VALUE is finite or NaN, +1 if it
  144. is +Infinity, -1 if it is -Infinity. */
  145. __MATHDECL_1 (int,__isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));
  146. /* Return nonzero if VALUE is finite and not NaN. */
  147. __MATHDECL_1 (int,__finite,, (_Mdouble_ __value)) __attribute__ ((__const__));
  148. _Mdouble_END_NAMESPACE
  149. #ifdef __USE_MISC
  150. # if (!defined __cplusplus \
  151. || __cplusplus < 201103L /* isinf conflicts with C++11. */ \
  152. || __MATH_DECLARING_DOUBLE == 0) /* isinff or isinfl don't. */
  153. /* Return 0 if VALUE is finite or NaN, +1 if it
  154. is +Infinity, -1 if it is -Infinity. */
  155. __MATHDECL_1 (int,isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));
  156. # endif
  157. /* Return nonzero if VALUE is finite and not NaN. */
  158. __MATHDECL_1 (int,finite,, (_Mdouble_ __value)) __attribute__ ((__const__));
  159. /* Return the remainder of X/Y. */
  160. __MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y));
  161. /* Return the fractional part of X after dividing out `ilogb (X)'. */
  162. __MATHCALL (significand,, (_Mdouble_ __x));
  163. #endif /* Use misc. */
  164. #ifdef __USE_ISOC99
  165. __BEGIN_NAMESPACE_C99
  166. /* Return X with its signed changed to Y's. */
  167. __MATHCALLX (copysign,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
  168. __END_NAMESPACE_C99
  169. #endif
  170. #ifdef __USE_ISOC99
  171. __BEGIN_NAMESPACE_C99
  172. /* Return representation of qNaN for double type. */
  173. __MATHCALLX (nan,, (const char *__tagb), (__const__));
  174. __END_NAMESPACE_C99
  175. #endif
  176. /* Return nonzero if VALUE is not a number. */
  177. __MATHDECL_1 (int,__isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
  178. #if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
  179. # if (!defined __cplusplus \
  180. || __cplusplus < 201103L /* isnan conflicts with C++11. */ \
  181. || __MATH_DECLARING_DOUBLE == 0) /* isnanf or isnanl don't. */
  182. /* Return nonzero if VALUE is not a number. */
  183. __MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
  184. # endif
  185. #endif
  186. #if defined __USE_MISC || (defined __USE_XOPEN && __MATH_DECLARING_DOUBLE)
  187. /* Bessel functions. */
  188. __MATHCALL (j0,, (_Mdouble_));
  189. __MATHCALL (j1,, (_Mdouble_));
  190. __MATHCALL (jn,, (int, _Mdouble_));
  191. __MATHCALL (y0,, (_Mdouble_));
  192. __MATHCALL (y1,, (_Mdouble_));
  193. __MATHCALL (yn,, (int, _Mdouble_));
  194. #endif
  195. #if defined __USE_XOPEN || defined __USE_ISOC99
  196. __BEGIN_NAMESPACE_C99
  197. /* Error and gamma functions. */
  198. __MATHCALL (erf,, (_Mdouble_));
  199. __MATHCALL (erfc,, (_Mdouble_));
  200. __MATHCALL (lgamma,, (_Mdouble_));
  201. __END_NAMESPACE_C99
  202. #endif
  203. #ifdef __USE_ISOC99
  204. __BEGIN_NAMESPACE_C99
  205. /* True gamma function. */
  206. __MATHCALL (tgamma,, (_Mdouble_));
  207. __END_NAMESPACE_C99
  208. #endif
  209. #if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
  210. /* Obsolete alias for `lgamma'. */
  211. __MATHCALL (gamma,, (_Mdouble_));
  212. #endif
  213. #ifdef __USE_MISC
  214. /* Reentrant version of lgamma. This function uses the global variable
  215. `signgam'. The reentrant version instead takes a pointer and stores
  216. the value through it. */
  217. __MATHCALL (lgamma,_r, (_Mdouble_, int *__signgamp));
  218. #endif
  219. #if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
  220. __BEGIN_NAMESPACE_C99
  221. /* Return the integer nearest X in the direction of the
  222. prevailing rounding mode. */
  223. __MATHCALL (rint,, (_Mdouble_ __x));
  224. /* Return X + epsilon if X < Y, X - epsilon if X > Y. */
  225. __MATHCALLX (nextafter,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
  226. # if defined __USE_ISOC99 && !defined __LDBL_COMPAT
  227. __MATHCALLX (nexttoward,, (_Mdouble_ __x, long double __y), (__const__));
  228. # endif
  229. /* Return the remainder of integer divison X / Y with infinite precision. */
  230. __MATHCALL (remainder,, (_Mdouble_ __x, _Mdouble_ __y));
  231. # ifdef __USE_ISOC99
  232. /* Return X times (2 to the Nth power). */
  233. __MATHCALL (scalbn,, (_Mdouble_ __x, int __n));
  234. # endif
  235. /* Return the binary exponent of X, which must be nonzero. */
  236. __MATHDECL (int,ilogb,, (_Mdouble_ __x));
  237. #endif
  238. #ifdef __USE_ISOC99
  239. /* Return X times (2 to the Nth power). */
  240. __MATHCALL (scalbln,, (_Mdouble_ __x, long int __n));
  241. /* Round X to integral value in floating-point format using current
  242. rounding direction, but do not raise inexact exception. */
  243. __MATHCALL (nearbyint,, (_Mdouble_ __x));
  244. /* Round X to nearest integral value, rounding halfway cases away from
  245. zero. */
  246. __MATHCALLX (round,, (_Mdouble_ __x), (__const__));
  247. /* Round X to the integral value in floating-point format nearest but
  248. not larger in magnitude. */
  249. __MATHCALLX (trunc,, (_Mdouble_ __x), (__const__));
  250. /* Compute remainder of X and Y and put in *QUO a value with sign of x/y
  251. and magnitude congruent `mod 2^n' to the magnitude of the integral
  252. quotient x/y, with n >= 3. */
  253. __MATHCALL (remquo,, (_Mdouble_ __x, _Mdouble_ __y, int *__quo));
  254. /* Conversion functions. */
  255. /* Round X to nearest integral value according to current rounding
  256. direction. */
  257. __MATHDECL (long int,lrint,, (_Mdouble_ __x));
  258. __extension__
  259. __MATHDECL (long long int,llrint,, (_Mdouble_ __x));
  260. /* Round X to nearest integral value, rounding halfway cases away from
  261. zero. */
  262. __MATHDECL (long int,lround,, (_Mdouble_ __x));
  263. __extension__
  264. __MATHDECL (long long int,llround,, (_Mdouble_ __x));
  265. /* Return positive difference between X and Y. */
  266. __MATHCALL (fdim,, (_Mdouble_ __x, _Mdouble_ __y));
  267. /* Return maximum numeric value from X and Y. */
  268. __MATHCALLX (fmax,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
  269. /* Return minimum numeric value from X and Y. */
  270. __MATHCALLX (fmin,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
  271. /* Classify given number. */
  272. __MATHDECL_1 (int, __fpclassify,, (_Mdouble_ __value))
  273. __attribute__ ((__const__));
  274. /* Test for negative number. */
  275. __MATHDECL_1 (int, __signbit,, (_Mdouble_ __value))
  276. __attribute__ ((__const__));
  277. /* Multiply-add function computed as a ternary operation. */
  278. __MATHCALL (fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z));
  279. #endif /* Use ISO C99. */
  280. #if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
  281. __END_NAMESPACE_C99
  282. #endif
  283. #ifdef __USE_GNU
  284. /* Test for signaling NaN. */
  285. __MATHDECL_1 (int, __issignaling,, (_Mdouble_ __value))
  286. __attribute__ ((__const__));
  287. #endif
  288. #if defined __USE_MISC || (defined __USE_XOPEN_EXTENDED \
  289. && __MATH_DECLARING_DOUBLE \
  290. && !defined __USE_XOPEN2K8)
  291. /* Return X times (2 to the Nth power). */
  292. __MATHCALL (scalb,, (_Mdouble_ __x, _Mdouble_ __n));
  293. #endif