mathcalls.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. /* Prototype declarations for math functions; helper file for <math.h>.
  2. Copyright (C) 1996-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. /* 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. /* Arc cosine of X. */
  38. __MATHCALL (acos,, (_Mdouble_ __x));
  39. /* Arc sine of X. */
  40. __MATHCALL (asin,, (_Mdouble_ __x));
  41. /* Arc tangent of X. */
  42. __MATHCALL (atan,, (_Mdouble_ __x));
  43. /* Arc tangent of Y/X. */
  44. __MATHCALL (atan2,, (_Mdouble_ __y, _Mdouble_ __x));
  45. /* Cosine of X. */
  46. __MATHCALL_VEC (cos,, (_Mdouble_ __x));
  47. /* Sine of X. */
  48. __MATHCALL_VEC (sin,, (_Mdouble_ __x));
  49. /* Tangent of X. */
  50. __MATHCALL (tan,, (_Mdouble_ __x));
  51. /* Hyperbolic functions. */
  52. /* Hyperbolic cosine of X. */
  53. __MATHCALL (cosh,, (_Mdouble_ __x));
  54. /* Hyperbolic sine of X. */
  55. __MATHCALL (sinh,, (_Mdouble_ __x));
  56. /* Hyperbolic tangent of X. */
  57. __MATHCALL (tanh,, (_Mdouble_ __x));
  58. #ifdef __USE_GNU
  59. /* Cosine and sine of X. */
  60. __MATHDECL_VEC (void,sincos,,
  61. (_Mdouble_ __x, _Mdouble_ *__sinx, _Mdouble_ *__cosx));
  62. #endif
  63. #if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
  64. /* Hyperbolic arc cosine of X. */
  65. __MATHCALL (acosh,, (_Mdouble_ __x));
  66. /* Hyperbolic arc sine of X. */
  67. __MATHCALL (asinh,, (_Mdouble_ __x));
  68. /* Hyperbolic arc tangent of X. */
  69. __MATHCALL (atanh,, (_Mdouble_ __x));
  70. #endif
  71. /* Exponential and logarithmic functions. */
  72. /* Exponential function of X. */
  73. __MATHCALL_VEC (exp,, (_Mdouble_ __x));
  74. /* Break VALUE into a normalized fraction and an integral power of 2. */
  75. __MATHCALL (frexp,, (_Mdouble_ __x, int *__exponent));
  76. /* X times (two to the EXP power). */
  77. __MATHCALL (ldexp,, (_Mdouble_ __x, int __exponent));
  78. /* Natural logarithm of X. */
  79. __MATHCALL_VEC (log,, (_Mdouble_ __x));
  80. /* Base-ten logarithm of X. */
  81. __MATHCALL (log10,, (_Mdouble_ __x));
  82. /* Break VALUE into integral and fractional parts. */
  83. __MATHCALL (modf,, (_Mdouble_ __x, _Mdouble_ *__iptr)) __nonnull ((2));
  84. #if __GLIBC_USE (IEC_60559_FUNCS_EXT)
  85. /* Compute exponent to base ten. */
  86. __MATHCALL (exp10,, (_Mdouble_ __x));
  87. #endif
  88. #if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
  89. /* Return exp(X) - 1. */
  90. __MATHCALL (expm1,, (_Mdouble_ __x));
  91. /* Return log(1 + X). */
  92. __MATHCALL (log1p,, (_Mdouble_ __x));
  93. /* Return the base 2 signed integral exponent of X. */
  94. __MATHCALL (logb,, (_Mdouble_ __x));
  95. #endif
  96. #ifdef __USE_ISOC99
  97. /* Compute base-2 exponential of X. */
  98. __MATHCALL (exp2,, (_Mdouble_ __x));
  99. /* Compute base-2 logarithm of X. */
  100. __MATHCALL (log2,, (_Mdouble_ __x));
  101. #endif
  102. /* Power functions. */
  103. /* Return X to the Y power. */
  104. __MATHCALL_VEC (pow,, (_Mdouble_ __x, _Mdouble_ __y));
  105. /* Return the square root of X. */
  106. __MATHCALL (sqrt,, (_Mdouble_ __x));
  107. #if defined __USE_XOPEN || defined __USE_ISOC99
  108. /* Return `sqrt(X*X + Y*Y)'. */
  109. __MATHCALL (hypot,, (_Mdouble_ __x, _Mdouble_ __y));
  110. #endif
  111. #if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
  112. /* Return the cube root of X. */
  113. __MATHCALL (cbrt,, (_Mdouble_ __x));
  114. #endif
  115. /* Nearest integer, absolute value, and remainder functions. */
  116. /* Smallest integral value not less than X. */
  117. __MATHCALLX (ceil,, (_Mdouble_ __x), (__const__));
  118. /* Absolute value of X. */
  119. __MATHCALLX (fabs,, (_Mdouble_ __x), (__const__));
  120. /* Largest integer not greater than X. */
  121. __MATHCALLX (floor,, (_Mdouble_ __x), (__const__));
  122. /* Floating-point modulo remainder of X/Y. */
  123. __MATHCALL (fmod,, (_Mdouble_ __x, _Mdouble_ __y));
  124. #ifdef __USE_MISC
  125. # if ((!defined __cplusplus \
  126. || __cplusplus < 201103L /* isinf conflicts with C++11. */ \
  127. || __MATH_DECLARING_DOUBLE == 0)) /* isinff or isinfl don't. */ \
  128. && !__MATH_DECLARING_FLOATN
  129. /* Return 0 if VALUE is finite or NaN, +1 if it
  130. is +Infinity, -1 if it is -Infinity. */
  131. __MATHDECL_1 (int,isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));
  132. # endif
  133. # if !__MATH_DECLARING_FLOATN
  134. /* Return nonzero if VALUE is finite and not NaN. */
  135. __MATHDECL_1 (int,finite,, (_Mdouble_ __value)) __attribute__ ((__const__));
  136. /* Return the remainder of X/Y. */
  137. __MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y));
  138. /* Return the fractional part of X after dividing out `ilogb (X)'. */
  139. __MATHCALL (significand,, (_Mdouble_ __x));
  140. # endif
  141. #endif /* Use misc. */
  142. #ifdef __USE_ISOC99
  143. /* Return X with its signed changed to Y's. */
  144. __MATHCALLX (copysign,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
  145. #endif
  146. #ifdef __USE_ISOC99
  147. /* Return representation of qNaN for double type. */
  148. __MATHCALL (nan,, (const char *__tagb));
  149. #endif
  150. #if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
  151. # if ((!defined __cplusplus \
  152. || __cplusplus < 201103L /* isnan conflicts with C++11. */ \
  153. || __MATH_DECLARING_DOUBLE == 0)) /* isnanf or isnanl don't. */ \
  154. && !__MATH_DECLARING_FLOATN
  155. /* Return nonzero if VALUE is not a number. */
  156. __MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
  157. # endif
  158. #endif
  159. #if defined __USE_MISC || (defined __USE_XOPEN && __MATH_DECLARING_DOUBLE)
  160. /* Bessel functions. */
  161. __MATHCALL (j0,, (_Mdouble_));
  162. __MATHCALL (j1,, (_Mdouble_));
  163. __MATHCALL (jn,, (int, _Mdouble_));
  164. __MATHCALL (y0,, (_Mdouble_));
  165. __MATHCALL (y1,, (_Mdouble_));
  166. __MATHCALL (yn,, (int, _Mdouble_));
  167. #endif
  168. #if defined __USE_XOPEN || defined __USE_ISOC99
  169. /* Error and gamma functions. */
  170. __MATHCALL (erf,, (_Mdouble_));
  171. __MATHCALL (erfc,, (_Mdouble_));
  172. __MATHCALL (lgamma,, (_Mdouble_));
  173. #endif
  174. #ifdef __USE_ISOC99
  175. /* True gamma function. */
  176. __MATHCALL (tgamma,, (_Mdouble_));
  177. #endif
  178. #if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
  179. # if !__MATH_DECLARING_FLOATN
  180. /* Obsolete alias for `lgamma'. */
  181. __MATHCALL (gamma,, (_Mdouble_));
  182. # endif
  183. #endif
  184. #ifdef __USE_MISC
  185. /* Reentrant version of lgamma. This function uses the global variable
  186. `signgam'. The reentrant version instead takes a pointer and stores
  187. the value through it. */
  188. __MATHCALL (lgamma,_r, (_Mdouble_, int *__signgamp));
  189. #endif
  190. #if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
  191. /* Return the integer nearest X in the direction of the
  192. prevailing rounding mode. */
  193. __MATHCALL (rint,, (_Mdouble_ __x));
  194. /* Return X + epsilon if X < Y, X - epsilon if X > Y. */
  195. __MATHCALL (nextafter,, (_Mdouble_ __x, _Mdouble_ __y));
  196. # if defined __USE_ISOC99 && !defined __LDBL_COMPAT && !__MATH_DECLARING_FLOATN
  197. __MATHCALL (nexttoward,, (_Mdouble_ __x, long double __y));
  198. # endif
  199. # if __GLIBC_USE (IEC_60559_BFP_EXT) || __MATH_DECLARING_FLOATN
  200. /* Return X - epsilon. */
  201. __MATHCALL (nextdown,, (_Mdouble_ __x));
  202. /* Return X + epsilon. */
  203. __MATHCALL (nextup,, (_Mdouble_ __x));
  204. # endif
  205. /* Return the remainder of integer divison X / Y with infinite precision. */
  206. __MATHCALL (remainder,, (_Mdouble_ __x, _Mdouble_ __y));
  207. # ifdef __USE_ISOC99
  208. /* Return X times (2 to the Nth power). */
  209. __MATHCALL (scalbn,, (_Mdouble_ __x, int __n));
  210. # endif
  211. /* Return the binary exponent of X, which must be nonzero. */
  212. __MATHDECL (int,ilogb,, (_Mdouble_ __x));
  213. #endif
  214. #if __GLIBC_USE (IEC_60559_BFP_EXT) || __MATH_DECLARING_FLOATN
  215. /* Like ilogb, but returning long int. */
  216. __MATHDECL (long int, llogb,, (_Mdouble_ __x));
  217. #endif
  218. #ifdef __USE_ISOC99
  219. /* Return X times (2 to the Nth power). */
  220. __MATHCALL (scalbln,, (_Mdouble_ __x, long int __n));
  221. /* Round X to integral value in floating-point format using current
  222. rounding direction, but do not raise inexact exception. */
  223. __MATHCALL (nearbyint,, (_Mdouble_ __x));
  224. /* Round X to nearest integral value, rounding halfway cases away from
  225. zero. */
  226. __MATHCALLX (round,, (_Mdouble_ __x), (__const__));
  227. /* Round X to the integral value in floating-point format nearest but
  228. not larger in magnitude. */
  229. __MATHCALLX (trunc,, (_Mdouble_ __x), (__const__));
  230. /* Compute remainder of X and Y and put in *QUO a value with sign of x/y
  231. and magnitude congruent `mod 2^n' to the magnitude of the integral
  232. quotient x/y, with n >= 3. */
  233. __MATHCALL (remquo,, (_Mdouble_ __x, _Mdouble_ __y, int *__quo));
  234. /* Conversion functions. */
  235. /* Round X to nearest integral value according to current rounding
  236. direction. */
  237. __MATHDECL (long int,lrint,, (_Mdouble_ __x));
  238. __extension__
  239. __MATHDECL (long long int,llrint,, (_Mdouble_ __x));
  240. /* Round X to nearest integral value, rounding halfway cases away from
  241. zero. */
  242. __MATHDECL (long int,lround,, (_Mdouble_ __x));
  243. __extension__
  244. __MATHDECL (long long int,llround,, (_Mdouble_ __x));
  245. /* Return positive difference between X and Y. */
  246. __MATHCALL (fdim,, (_Mdouble_ __x, _Mdouble_ __y));
  247. /* Return maximum numeric value from X and Y. */
  248. __MATHCALLX (fmax,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
  249. /* Return minimum numeric value from X and Y. */
  250. __MATHCALLX (fmin,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
  251. /* Multiply-add function computed as a ternary operation. */
  252. __MATHCALL (fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z));
  253. #endif /* Use ISO C99. */
  254. #if __GLIBC_USE (IEC_60559_BFP_EXT) || __MATH_DECLARING_FLOATN
  255. /* Round X to nearest integer value, rounding halfway cases to even. */
  256. __MATHCALLX (roundeven,, (_Mdouble_ __x), (__const__));
  257. /* Round X to nearest signed integer value, not raising inexact, with
  258. control of rounding direction and width of result. */
  259. __MATHDECL (__intmax_t, fromfp,, (_Mdouble_ __x, int __round,
  260. unsigned int __width));
  261. /* Round X to nearest unsigned integer value, not raising inexact,
  262. with control of rounding direction and width of result. */
  263. __MATHDECL (__uintmax_t, ufromfp,, (_Mdouble_ __x, int __round,
  264. unsigned int __width));
  265. /* Round X to nearest signed integer value, raising inexact for
  266. non-integers, with control of rounding direction and width of
  267. result. */
  268. __MATHDECL (__intmax_t, fromfpx,, (_Mdouble_ __x, int __round,
  269. unsigned int __width));
  270. /* Round X to nearest unsigned integer value, raising inexact for
  271. non-integers, with control of rounding direction and width of
  272. result. */
  273. __MATHDECL (__uintmax_t, ufromfpx,, (_Mdouble_ __x, int __round,
  274. unsigned int __width));
  275. /* Return value with maximum magnitude. */
  276. __MATHCALLX (fmaxmag,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
  277. /* Return value with minimum magnitude. */
  278. __MATHCALLX (fminmag,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
  279. /* Total order operation. */
  280. __MATHDECL_1 (int, totalorder,, (_Mdouble_ __x, _Mdouble_ __y))
  281. __attribute__ ((__const__));
  282. /* Total order operation on absolute values. */
  283. __MATHDECL_1 (int, totalordermag,, (_Mdouble_ __x, _Mdouble_ __y))
  284. __attribute__ ((__const__));
  285. /* Canonicalize floating-point representation. */
  286. __MATHDECL_1 (int, canonicalize,, (_Mdouble_ *__cx, const _Mdouble_ *__x));
  287. /* Get NaN payload. */
  288. __MATHCALL (getpayload,, (const _Mdouble_ *__x));
  289. /* Set quiet NaN payload. */
  290. __MATHDECL_1 (int, setpayload,, (_Mdouble_ *__x, _Mdouble_ __payload));
  291. /* Set signaling NaN payload. */
  292. __MATHDECL_1 (int, setpayloadsig,, (_Mdouble_ *__x, _Mdouble_ __payload));
  293. #endif
  294. #if (defined __USE_MISC || (defined __USE_XOPEN_EXTENDED \
  295. && __MATH_DECLARING_DOUBLE \
  296. && !defined __USE_XOPEN2K8)) \
  297. && !__MATH_DECLARING_FLOATN
  298. /* Return X times (2 to the Nth power). */
  299. __MATHCALL (scalb,, (_Mdouble_ __x, _Mdouble_ __n));
  300. #endif