mathcalls.h 16 KB

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