mathcalls.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. /* Prototype declarations for math functions; helper file for <math.h>.
  2. Copyright (C) 1996-2002, 2003, 2006 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. /* __MATHCALLX(type,function,[suffix],args,attrib) and
  37. * __MATHCALLI(type,function,[suffix],args) include libm_hidden_proto
  38. * (for "double" versions only, xxxf and xxxl do not get this treatment).
  39. *
  40. * __MATHDECL(type,function,[suffix],args) does not.
  41. * __MATHCALL(function,[suffix],args) also does not
  42. * (it is just a shortcut to __MATHDECL(_Mdouble_,function,[suffix],args)).
  43. *
  44. * __MATHDECL_PRIV(type,function,[suffix],args,attrib)
  45. * includes libm_hidden_proto (always) and declares __foo, not foo.
  46. */
  47. /* Trigonometric functions. */
  48. _Mdouble_BEGIN_NAMESPACE
  49. /* Arc cosine of X. */
  50. __MATHCALLI (acos,, (_Mdouble_ __x))
  51. /* Arc sine of X. */
  52. __MATHCALLI (asin,, (_Mdouble_ __x))
  53. /* Arc tangent of X. */
  54. __MATHCALLI (atan,, (_Mdouble_ __x))
  55. /* Arc tangent of Y/X. */
  56. __MATHCALLI (atan2,, (_Mdouble_ __y, _Mdouble_ __x))
  57. /* Cosine of X. */
  58. __MATHCALLI (cos,, (_Mdouble_ __x))
  59. # if defined _LIBC && defined _Mlong_double_
  60. libm_hidden_proto(cosl)
  61. # endif
  62. # if defined _LIBC && defined _Mfloat_
  63. libm_hidden_proto(cosf)
  64. # endif
  65. /* Sine of X. */
  66. __MATHCALLI (sin,, (_Mdouble_ __x))
  67. # if defined _LIBC && defined _Mlong_double_
  68. libm_hidden_proto(sinl)
  69. # endif
  70. # if defined _LIBC && defined _Mfloat_
  71. libm_hidden_proto(sinf)
  72. # endif
  73. /* Tangent of X. */
  74. __MATHCALLI (tan,, (_Mdouble_ __x))
  75. /* Hyperbolic functions. */
  76. /* Hyperbolic cosine of X. */
  77. __MATHCALLI (cosh,, (_Mdouble_ __x))
  78. /* Hyperbolic sine of X. */
  79. __MATHCALLI (sinh,, (_Mdouble_ __x))
  80. /* Hyperbolic tangent of X. */
  81. __MATHCALLI (tanh,, (_Mdouble_ __x))
  82. _Mdouble_END_NAMESPACE
  83. #if defined __USE_GNU
  84. /* Cosine and sine of X. */
  85. __MATHDECL (void,sincos,,
  86. (_Mdouble_ __x, _Mdouble_ *__sinx, _Mdouble_ *__cosx))
  87. #endif
  88. #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
  89. __BEGIN_NAMESPACE_C99
  90. /* Hyperbolic arc cosine of X. */
  91. __MATHCALLI (acosh,, (_Mdouble_ __x))
  92. /* Hyperbolic arc sine of X. */
  93. __MATHCALLI (asinh,, (_Mdouble_ __x))
  94. /* Hyperbolic arc tangent of X. */
  95. __MATHCALLI (atanh,, (_Mdouble_ __x))
  96. __END_NAMESPACE_C99
  97. #endif
  98. /* Exponential and logarithmic functions. */
  99. _Mdouble_BEGIN_NAMESPACE
  100. /* Exponential function of X. */
  101. __MATHCALLI (exp,, (_Mdouble_ __x))
  102. # if defined _LIBC && defined _Mlong_double_
  103. libm_hidden_proto(expl)
  104. # endif
  105. /* Break VALUE into a normalized fraction and an integral power of 2. */
  106. __MATHCALLI (frexp,, (_Mdouble_ __x, int *__exponent))
  107. /* X times (two to the EXP power). */
  108. __MATHCALLI (ldexp,, (_Mdouble_ __x, int __exponent))
  109. /* Natural logarithm of X. */
  110. __MATHCALLI (log,, (_Mdouble_ __x))
  111. /* Base-ten logarithm of X. */
  112. __MATHCALLI (log10,, (_Mdouble_ __x))
  113. /* Break VALUE into integral and fractional parts. */
  114. __MATHCALLI (modf,, (_Mdouble_ __x, _Mdouble_ *__iptr))
  115. _Mdouble_END_NAMESPACE
  116. #if defined __USE_GNU
  117. /* A function missing in all standards: compute exponent to base ten. */
  118. __MATHCALLI (exp10,, (_Mdouble_ __x))
  119. /* Another name occasionally used. */
  120. __MATHCALLI (pow10,, (_Mdouble_ __x))
  121. #endif
  122. #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
  123. __BEGIN_NAMESPACE_C99
  124. /* Return exp(X) - 1. */
  125. __MATHCALLI (expm1,, (_Mdouble_ __x))
  126. /* Return log(1 + X). */
  127. __MATHCALLI (log1p,, (_Mdouble_ __x))
  128. /* Return the base 2 signed integral exponent of X. */
  129. __MATHCALLI (logb,, (_Mdouble_ __x))
  130. __END_NAMESPACE_C99
  131. #endif
  132. #ifdef __USE_ISOC99
  133. __BEGIN_NAMESPACE_C99
  134. /* Compute base-2 exponential of X. */
  135. __MATHCALLI (exp2,, (_Mdouble_ __x))
  136. /* Compute base-2 logarithm of X. */
  137. __MATHCALLI (log2,, (_Mdouble_ __x))
  138. __END_NAMESPACE_C99
  139. #endif
  140. /* Power functions. */
  141. _Mdouble_BEGIN_NAMESPACE
  142. /* Return X to the Y power. */
  143. __MATHCALLI (pow,, (_Mdouble_ __x, _Mdouble_ __y))
  144. /* Return the square root of X. */
  145. __MATHCALLI (sqrt,, (_Mdouble_ __x))
  146. _Mdouble_END_NAMESPACE
  147. #if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC99
  148. __BEGIN_NAMESPACE_C99
  149. /* Return `sqrt(X*X + Y*Y)'. */
  150. __MATHCALLI (hypot,, (_Mdouble_ __x, _Mdouble_ __y))
  151. # if defined _LIBC && defined _Mlong_double_
  152. libm_hidden_proto(hypotl)
  153. # endif
  154. __END_NAMESPACE_C99
  155. #endif
  156. #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
  157. __BEGIN_NAMESPACE_C99
  158. /* Return the cube root of X. */
  159. __MATHCALLI (cbrt,, (_Mdouble_ __x))
  160. __END_NAMESPACE_C99
  161. #endif
  162. /* Nearest integer, absolute value, and remainder functions. */
  163. _Mdouble_BEGIN_NAMESPACE
  164. /* Smallest integral value not less than X. */
  165. __MATHCALLX (ceil,, (_Mdouble_ __x), (__const__))
  166. /* Absolute value of X. */
  167. __MATHCALLX (fabs,, (_Mdouble_ __x), (__const__))
  168. /* Largest integer not greater than X. */
  169. __MATHCALLX (floor,, (_Mdouble_ __x), (__const__))
  170. /* Floating-point modulo remainder of X/Y. */
  171. __MATHCALLI (fmod,, (_Mdouble_ __x, _Mdouble_ __y))
  172. /* Return 0 if VALUE is finite or NaN, +1 if it
  173. is +Infinity, -1 if it is -Infinity. */
  174. __MATHDECL_PRIV (int,isinf,, (_Mdouble_ __value), (__const__))
  175. /* Return nonzero if VALUE is finite and not NaN. */
  176. __MATHDECL_PRIV (int,finite,, (_Mdouble_ __value), (__const__))
  177. _Mdouble_END_NAMESPACE
  178. #ifdef __USE_MISC
  179. #if 0
  180. /* Return 0 if VALUE is finite or NaN, +1 if it
  181. is +Infinity, -1 if it is -Infinity. */
  182. __MATHDECL_PRIV (int,isinf,, (_Mdouble_ __value), (__const__))
  183. /* Return nonzero if VALUE is finite and not NaN. */
  184. __MATHDECL_PRIV (int,finite,, (_Mdouble_ __value), (__const__))
  185. #endif
  186. /* Return the remainder of X/Y. */
  187. __MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y))
  188. /* Return the fractional part of X after dividing out `ilogb (X)'. */
  189. __MATHCALLI (significand,, (_Mdouble_ __x))
  190. #endif /* Use misc. */
  191. #if defined __USE_MISC || defined __USE_ISOC99
  192. __BEGIN_NAMESPACE_C99
  193. /* Return X with its signed changed to Y's. */
  194. __MATHCALLX (copysign,, (_Mdouble_ __x, _Mdouble_ __y), (__const__))
  195. __END_NAMESPACE_C99
  196. #endif
  197. #ifdef __USE_ISOC99
  198. __BEGIN_NAMESPACE_C99
  199. /* Return representation of NaN for double type. */
  200. __MATHCALLX (nan,, (const char *__tagb), (__const__))
  201. __END_NAMESPACE_C99
  202. #endif
  203. #if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC99
  204. /* Return nonzero if VALUE is not a number. */
  205. __BEGIN_NAMESPACE_C99
  206. __MATHDECL_PRIV (int,isnan,, (_Mdouble_ __value), (__const__))
  207. __END_NAMESPACE_C99
  208. #endif
  209. #if defined __USE_MISC || defined __USE_XOPEN
  210. # ifdef __DO_XSI_MATH__
  211. /* Bessel functions. */
  212. __MATHCALL (j0,, (_Mdouble_))
  213. __MATHCALL (j1,, (_Mdouble_))
  214. __MATHCALL (jn,, (int, _Mdouble_))
  215. __MATHCALL (y0,, (_Mdouble_))
  216. __MATHCALL (y1,, (_Mdouble_))
  217. __MATHCALL (yn,, (int, _Mdouble_))
  218. # endif
  219. #endif
  220. #if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC99
  221. __BEGIN_NAMESPACE_C99
  222. /* Error and gamma functions. */
  223. __MATHCALLI (erf,, (_Mdouble_))
  224. __MATHCALLI (erfc,, (_Mdouble_))
  225. __MATHCALLI (lgamma,, (_Mdouble_))
  226. __END_NAMESPACE_C99
  227. #endif
  228. #ifdef __USE_ISOC99
  229. __BEGIN_NAMESPACE_C99
  230. /* True gamma function. */
  231. __MATHCALLI (tgamma,, (_Mdouble_))
  232. __END_NAMESPACE_C99
  233. #endif
  234. #if defined __USE_MISC || defined __USE_XOPEN
  235. /* Obsolete alias for `lgamma'. */
  236. __MATHCALLI (gamma,, (_Mdouble_))
  237. #endif
  238. #ifdef __USE_MISC
  239. /* Reentrant version of lgamma. This function uses the global variable
  240. `signgam'. The reentrant version instead takes a pointer and stores
  241. the value through it. */
  242. __MATHCALL (lgamma,_r, (_Mdouble_, int *__signgamp))
  243. /* __MATHCALLI does not work here, probably due to ,_r, */
  244. libm_hidden_proto(lgamma_r)
  245. #endif
  246. #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
  247. __BEGIN_NAMESPACE_C99
  248. /* Return the integer nearest X in the direction of the
  249. prevailing rounding mode. */
  250. __MATHCALLI (rint,, (_Mdouble_ __x))
  251. /* Return X + epsilon if X < Y, X - epsilon if X > Y. */
  252. __MATHCALLX (nextafter,, (_Mdouble_ __x, _Mdouble_ __y), (__const__))
  253. # if defined _LIBC && defined _Mlong_double_
  254. libm_hidden_proto(nextafterl)
  255. # endif
  256. # if defined __USE_ISOC99 && !defined __LDBL_COMPAT
  257. __MATHCALLX (nexttoward,, (_Mdouble_ __x, long double __y), (__const__))
  258. # endif
  259. /* Return the remainder of integer divison X / Y with infinite precision. */
  260. __MATHCALLI (remainder,, (_Mdouble_ __x, _Mdouble_ __y))
  261. # if defined __USE_MISC || defined __USE_ISOC99
  262. /* Return X times (2 to the Nth power). */
  263. __MATHCALLI (scalbn,, (_Mdouble_ __x, int __n))
  264. # endif
  265. /* Return the binary exponent of X, which must be nonzero. */
  266. __MATHDECLI (int,ilogb,, (_Mdouble_ __x))
  267. #endif
  268. #ifdef __USE_ISOC99
  269. /* Return X times (2 to the Nth power). */
  270. __MATHCALLI (scalbln,, (_Mdouble_ __x, long int __n))
  271. /* Round X to integral value in floating-point format using current
  272. rounding direction, but do not raise inexact exception. */
  273. __MATHCALLI (nearbyint,, (_Mdouble_ __x))
  274. /* Round X to nearest integral value, rounding halfway cases away from
  275. zero. */
  276. __MATHCALLX (round,, (_Mdouble_ __x), (__const__))
  277. /* Round X to the integral value in floating-point format nearest but
  278. not larger in magnitude. */
  279. __MATHCALLX (trunc,, (_Mdouble_ __x), (__const__))
  280. /* Compute remainder of X and Y and put in *QUO a value with sign of x/y
  281. and magnitude congruent `mod 2^n' to the magnitude of the integral
  282. quotient x/y, with n >= 3. */
  283. __MATHCALLI (remquo,, (_Mdouble_ __x, _Mdouble_ __y, int *__quo))
  284. /* Conversion functions. */
  285. /* Round X to nearest integral value according to current rounding
  286. direction. */
  287. __MATHDECLI (long int,lrint,, (_Mdouble_ __x))
  288. __MATHDECLI (long long int,llrint,, (_Mdouble_ __x))
  289. /* Round X to nearest integral value, rounding halfway cases away from
  290. zero. */
  291. __MATHDECLI (long int,lround,, (_Mdouble_ __x))
  292. __MATHDECLI (long long int,llround,, (_Mdouble_ __x))
  293. /* Return positive difference between X and Y. */
  294. __MATHCALLI (fdim,, (_Mdouble_ __x, _Mdouble_ __y))
  295. /* Return maximum numeric value from X and Y. */
  296. __MATHCALLI (fmax,, (_Mdouble_ __x, _Mdouble_ __y))
  297. /* Return minimum numeric value from X and Y. */
  298. __MATHCALLI (fmin,, (_Mdouble_ __x, _Mdouble_ __y))
  299. /* Classify given number. */
  300. __MATHDECL_PRIV (int, fpclassify,, (_Mdouble_ __value), (__const__))
  301. /* Test for negative number. */
  302. __MATHDECL_PRIV (int, signbit,, (_Mdouble_ __value), (__const__))
  303. /* Multiply-add function computed as a ternary operation. */
  304. __MATHCALLI (fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z))
  305. #endif /* Use ISO C99. */
  306. #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
  307. __END_NAMESPACE_C99
  308. #endif
  309. #if (defined __USE_MISC || defined __USE_XOPEN_EXTENDED) \
  310. && defined __UCLIBC_SUSV3_LEGACY__
  311. /* Return X times (2 to the Nth power). */
  312. __MATHCALLI (scalb,, (_Mdouble_ __x, _Mdouble_ __n))
  313. #endif