1 | /* Prototype declarations for math functions; helper file for <math.h>. |
---|---|

2 | Copyright (C) 1996-2017 Free Software Foundation, Inc. |

3 | This file is part of the GNU C Library. |

4 | |

5 | The GNU C Library is free software; you can redistribute it and/or |

6 | modify it under the terms of the GNU Lesser General Public |

7 | License as published by the Free Software Foundation; either |

8 | version 2.1 of the License, or (at your option) any later version. |

9 | |

10 | The GNU C Library is distributed in the hope that it will be useful, |

11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |

12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |

13 | Lesser General Public License for more details. |

14 | |

15 | You should have received a copy of the GNU Lesser General Public |

16 | License along with the GNU C Library; if not, see |

17 | <http://www.gnu.org/licenses/>. */ |

18 | |

19 | /* NOTE: Because of the special way this file is used by <math.h>, this |

20 | file must NOT be protected from multiple inclusion as header files |

21 | usually are. |

22 | |

23 | This file provides prototype declarations for the math functions. |

24 | Most functions are declared using the macro: |

25 | |

26 | __MATHCALL (NAME,[_r], (ARGS...)); |

27 | |

28 | This means there is a function `NAME' returning `double' and a function |

29 | `NAMEf' returning `float'. Each place `_Mdouble_' appears in the |

30 | prototype, that is actually `double' in the prototype for `NAME' and |

31 | `float' in the prototype for `NAMEf'. Reentrant variant functions are |

32 | called `NAME_r' and `NAMEf_r'. |

33 | |

34 | Functions returning other types like `int' are declared using the macro: |

35 | |

36 | __MATHDECL (TYPE, NAME,[_r], (ARGS...)); |

37 | |

38 | This is just like __MATHCALL but for a function returning `TYPE' |

39 | instead of `_Mdouble_'. In all of these cases, there is still |

40 | both a `NAME' and a `NAMEf' that takes `float' arguments. |

41 | |

42 | Note that there must be no whitespace before the argument passed for |

43 | NAME, to make token pasting work with -traditional. */ |

44 | |

45 | #ifndef _MATH_H |

46 | # error "Never include <bits/mathcalls.h> directly; include <math.h> instead." |

47 | #endif |

48 | |

49 | |

50 | /* Trigonometric functions. */ |

51 | |

52 | /* Arc cosine of X. */ |

53 | __MATHCALL (acos,, (_Mdouble_ __x)); |

54 | /* Arc sine of X. */ |

55 | __MATHCALL (asin,, (_Mdouble_ __x)); |

56 | /* Arc tangent of X. */ |

57 | __MATHCALL (atan,, (_Mdouble_ __x)); |

58 | /* Arc tangent of Y/X. */ |

59 | __MATHCALL (atan2,, (_Mdouble_ __y, _Mdouble_ __x)); |

60 | |

61 | /* Cosine of X. */ |

62 | __MATHCALL_VEC (cos,, (_Mdouble_ __x)); |

63 | /* Sine of X. */ |

64 | __MATHCALL_VEC (sin,, (_Mdouble_ __x)); |

65 | /* Tangent of X. */ |

66 | __MATHCALL (tan,, (_Mdouble_ __x)); |

67 | |

68 | /* Hyperbolic functions. */ |

69 | |

70 | /* Hyperbolic cosine of X. */ |

71 | __MATHCALL (cosh,, (_Mdouble_ __x)); |

72 | /* Hyperbolic sine of X. */ |

73 | __MATHCALL (sinh,, (_Mdouble_ __x)); |

74 | /* Hyperbolic tangent of X. */ |

75 | __MATHCALL (tanh,, (_Mdouble_ __x)); |

76 | |

77 | #ifdef __USE_GNU |

78 | /* Cosine and sine of X. */ |

79 | __MATHDECL_VEC (void,sincos,, |

80 | (_Mdouble_ __x, _Mdouble_ *__sinx, _Mdouble_ *__cosx)); |

81 | #endif |

82 | |

83 | #if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99 |

84 | /* Hyperbolic arc cosine of X. */ |

85 | __MATHCALL (acosh,, (_Mdouble_ __x)); |

86 | /* Hyperbolic arc sine of X. */ |

87 | __MATHCALL (asinh,, (_Mdouble_ __x)); |

88 | /* Hyperbolic arc tangent of X. */ |

89 | __MATHCALL (atanh,, (_Mdouble_ __x)); |

90 | #endif |

91 | |

92 | /* Exponential and logarithmic functions. */ |

93 | |

94 | /* Exponential function of X. */ |

95 | __MATHCALL_VEC (exp,, (_Mdouble_ __x)); |

96 | |

97 | /* Break VALUE into a normalized fraction and an integral power of 2. */ |

98 | __MATHCALL (frexp,, (_Mdouble_ __x, int *__exponent)); |

99 | |

100 | /* X times (two to the EXP power). */ |

101 | __MATHCALL (ldexp,, (_Mdouble_ __x, int __exponent)); |

102 | |

103 | /* Natural logarithm of X. */ |

104 | __MATHCALL_VEC (log,, (_Mdouble_ __x)); |

105 | |

106 | /* Base-ten logarithm of X. */ |

107 | __MATHCALL (log10,, (_Mdouble_ __x)); |

108 | |

109 | /* Break VALUE into integral and fractional parts. */ |

110 | __MATHCALL (modf,, (_Mdouble_ __x, _Mdouble_ *__iptr)) __nonnull ((2)); |

111 | |

112 | #if __GLIBC_USE (IEC_60559_FUNCS_EXT) |

113 | /* Compute exponent to base ten. */ |

114 | __MATHCALL (exp10,, (_Mdouble_ __x)); |

115 | #endif |

116 | #ifdef __USE_GNU |

117 | /* Another name occasionally used. */ |

118 | # if !__MATH_DECLARING_FLOATN |

119 | __MATHCALL (pow10,, (_Mdouble_ __x)); |

120 | # endif |

121 | #endif |

122 | |

123 | #if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99 |

124 | /* Return exp(X) - 1. */ |

125 | __MATHCALL (expm1,, (_Mdouble_ __x)); |

126 | |

127 | /* Return log(1 + X). */ |

128 | __MATHCALL (log1p,, (_Mdouble_ __x)); |

129 | |

130 | /* Return the base 2 signed integral exponent of X. */ |

131 | __MATHCALL (logb,, (_Mdouble_ __x)); |

132 | #endif |

133 | |

134 | #ifdef __USE_ISOC99 |

135 | /* Compute base-2 exponential of X. */ |

136 | __MATHCALL (exp2,, (_Mdouble_ __x)); |

137 | |

138 | /* Compute base-2 logarithm of X. */ |

139 | __MATHCALL (log2,, (_Mdouble_ __x)); |

140 | #endif |

141 | |

142 | |

143 | /* Power functions. */ |

144 | |

145 | /* Return X to the Y power. */ |

146 | __MATHCALL_VEC (pow,, (_Mdouble_ __x, _Mdouble_ __y)); |

147 | |

148 | /* Return the square root of X. */ |

149 | __MATHCALL (sqrt,, (_Mdouble_ __x)); |

150 | |

151 | #if defined __USE_XOPEN || defined __USE_ISOC99 |

152 | /* Return `sqrt(X*X + Y*Y)'. */ |

153 | __MATHCALL (hypot,, (_Mdouble_ __x, _Mdouble_ __y)); |

154 | #endif |

155 | |

156 | #if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99 |

157 | /* Return the cube root of X. */ |

158 | __MATHCALL (cbrt,, (_Mdouble_ __x)); |

159 | #endif |

160 | |

161 | |

162 | /* Nearest integer, absolute value, and remainder functions. */ |

163 | |

164 | /* Smallest integral value not less than X. */ |

165 | __MATHCALLX (ceil,, (_Mdouble_ __x), (__const__)); |

166 | |

167 | /* Absolute value of X. */ |

168 | __MATHCALLX (fabs,, (_Mdouble_ __x), (__const__)); |

169 | |

170 | /* Largest integer not greater than X. */ |

171 | __MATHCALLX (floor,, (_Mdouble_ __x), (__const__)); |

172 | |

173 | /* Floating-point modulo remainder of X/Y. */ |

174 | __MATHCALL (fmod,, (_Mdouble_ __x, _Mdouble_ __y)); |

175 | |

176 | #ifdef __USE_MISC |

177 | # if ((!defined __cplusplus \ |

178 | || __cplusplus < 201103L /* isinf conflicts with C++11. */ \ |

179 | || __MATH_DECLARING_DOUBLE == 0)) /* isinff or isinfl don't. */ \ |

180 | && !__MATH_DECLARING_FLOATN |

181 | /* Return 0 if VALUE is finite or NaN, +1 if it |

182 | is +Infinity, -1 if it is -Infinity. */ |

183 | __MATHDECL_1 (int,isinf,, (_Mdouble_ __value)) __attribute__ ((__const__)); |

184 | # endif |

185 | |

186 | # if !__MATH_DECLARING_FLOATN |

187 | /* Return nonzero if VALUE is finite and not NaN. */ |

188 | __MATHDECL_1 (int,finite,, (_Mdouble_ __value)) __attribute__ ((__const__)); |

189 | |

190 | /* Return the remainder of X/Y. */ |

191 | __MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y)); |

192 | |

193 | |

194 | /* Return the fractional part of X after dividing out `ilogb (X)'. */ |

195 | __MATHCALL (significand,, (_Mdouble_ __x)); |

196 | # endif |

197 | |

198 | #endif /* Use misc. */ |

199 | |

200 | #ifdef __USE_ISOC99 |

201 | /* Return X with its signed changed to Y's. */ |

202 | __MATHCALLX (copysign,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); |

203 | #endif |

204 | |

205 | #ifdef __USE_ISOC99 |

206 | /* Return representation of qNaN for double type. */ |

207 | __MATHCALLX (nan,, (const char *__tagb), (__const__)); |

208 | #endif |

209 | |

210 | |

211 | #if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K) |

212 | # if ((!defined __cplusplus \ |

213 | || __cplusplus < 201103L /* isnan conflicts with C++11. */ \ |

214 | || __MATH_DECLARING_DOUBLE == 0)) /* isnanf or isnanl don't. */ \ |

215 | && !__MATH_DECLARING_FLOATN |

216 | /* Return nonzero if VALUE is not a number. */ |

217 | __MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__)); |

218 | # endif |

219 | #endif |

220 | |

221 | #if defined __USE_MISC || (defined __USE_XOPEN && __MATH_DECLARING_DOUBLE) |

222 | /* Bessel functions. */ |

223 | __MATHCALL (j0,, (_Mdouble_)); |

224 | __MATHCALL (j1,, (_Mdouble_)); |

225 | __MATHCALL (jn,, (int, _Mdouble_)); |

226 | __MATHCALL (y0,, (_Mdouble_)); |

227 | __MATHCALL (y1,, (_Mdouble_)); |

228 | __MATHCALL (yn,, (int, _Mdouble_)); |

229 | #endif |

230 | |

231 | |

232 | #if defined __USE_XOPEN || defined __USE_ISOC99 |

233 | /* Error and gamma functions. */ |

234 | __MATHCALL (erf,, (_Mdouble_)); |

235 | __MATHCALL (erfc,, (_Mdouble_)); |

236 | __MATHCALL (lgamma,, (_Mdouble_)); |

237 | #endif |

238 | |

239 | #ifdef __USE_ISOC99 |

240 | /* True gamma function. */ |

241 | __MATHCALL (tgamma,, (_Mdouble_)); |

242 | #endif |

243 | |

244 | #if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K) |

245 | # if !__MATH_DECLARING_FLOATN |

246 | /* Obsolete alias for `lgamma'. */ |

247 | __MATHCALL (gamma,, (_Mdouble_)); |

248 | # endif |

249 | #endif |

250 | |

251 | #ifdef __USE_MISC |

252 | /* Reentrant version of lgamma. This function uses the global variable |

253 | `signgam'. The reentrant version instead takes a pointer and stores |

254 | the value through it. */ |

255 | __MATHCALL (lgamma,_r, (_Mdouble_, int *__signgamp)); |

256 | #endif |

257 | |

258 | |

259 | #if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99 |

260 | /* Return the integer nearest X in the direction of the |

261 | prevailing rounding mode. */ |

262 | __MATHCALL (rint,, (_Mdouble_ __x)); |

263 | |

264 | /* Return X + epsilon if X < Y, X - epsilon if X > Y. */ |

265 | __MATHCALLX (nextafter,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); |

266 | # if defined __USE_ISOC99 && !defined __LDBL_COMPAT && !__MATH_DECLARING_FLOATN |

267 | __MATHCALLX (nexttoward,, (_Mdouble_ __x, long double __y), (__const__)); |

268 | # endif |

269 | |

270 | # if __GLIBC_USE (IEC_60559_BFP_EXT) || __MATH_DECLARING_FLOATN |

271 | /* Return X - epsilon. */ |

272 | __MATHCALL (nextdown,, (_Mdouble_ __x)); |

273 | /* Return X + epsilon. */ |

274 | __MATHCALL (nextup,, (_Mdouble_ __x)); |

275 | # endif |

276 | |

277 | /* Return the remainder of integer divison X / Y with infinite precision. */ |

278 | __MATHCALL (remainder,, (_Mdouble_ __x, _Mdouble_ __y)); |

279 | |

280 | # ifdef __USE_ISOC99 |

281 | /* Return X times (2 to the Nth power). */ |

282 | __MATHCALL (scalbn,, (_Mdouble_ __x, int __n)); |

283 | # endif |

284 | |

285 | /* Return the binary exponent of X, which must be nonzero. */ |

286 | __MATHDECL (int,ilogb,, (_Mdouble_ __x)); |

287 | #endif |

288 | |

289 | #if __GLIBC_USE (IEC_60559_BFP_EXT) || __MATH_DECLARING_FLOATN |

290 | /* Like ilogb, but returning long int. */ |

291 | __MATHDECL (long int, llogb,, (_Mdouble_ __x)); |

292 | #endif |

293 | |

294 | #ifdef __USE_ISOC99 |

295 | /* Return X times (2 to the Nth power). */ |

296 | __MATHCALL (scalbln,, (_Mdouble_ __x, long int __n)); |

297 | |

298 | /* Round X to integral value in floating-point format using current |

299 | rounding direction, but do not raise inexact exception. */ |

300 | __MATHCALL (nearbyint,, (_Mdouble_ __x)); |

301 | |

302 | /* Round X to nearest integral value, rounding halfway cases away from |

303 | zero. */ |

304 | __MATHCALLX (round,, (_Mdouble_ __x), (__const__)); |

305 | |

306 | /* Round X to the integral value in floating-point format nearest but |

307 | not larger in magnitude. */ |

308 | __MATHCALLX (trunc,, (_Mdouble_ __x), (__const__)); |

309 | |

310 | /* Compute remainder of X and Y and put in *QUO a value with sign of x/y |

311 | and magnitude congruent `mod 2^n' to the magnitude of the integral |

312 | quotient x/y, with n >= 3. */ |

313 | __MATHCALL (remquo,, (_Mdouble_ __x, _Mdouble_ __y, int *__quo)); |

314 | |

315 | |

316 | /* Conversion functions. */ |

317 | |

318 | /* Round X to nearest integral value according to current rounding |

319 | direction. */ |

320 | __MATHDECL (long int,lrint,, (_Mdouble_ __x)); |

321 | __extension__ |

322 | __MATHDECL (long long int,llrint,, (_Mdouble_ __x)); |

323 | |

324 | /* Round X to nearest integral value, rounding halfway cases away from |

325 | zero. */ |

326 | __MATHDECL (long int,lround,, (_Mdouble_ __x)); |

327 | __extension__ |

328 | __MATHDECL (long long int,llround,, (_Mdouble_ __x)); |

329 | |

330 | |

331 | /* Return positive difference between X and Y. */ |

332 | __MATHCALL (fdim,, (_Mdouble_ __x, _Mdouble_ __y)); |

333 | |

334 | /* Return maximum numeric value from X and Y. */ |

335 | __MATHCALLX (fmax,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); |

336 | |

337 | /* Return minimum numeric value from X and Y. */ |

338 | __MATHCALLX (fmin,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); |

339 | |

340 | /* Multiply-add function computed as a ternary operation. */ |

341 | __MATHCALL (fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z)); |

342 | #endif /* Use ISO C99. */ |

343 | |

344 | #if __GLIBC_USE (IEC_60559_BFP_EXT) || __MATH_DECLARING_FLOATN |

345 | /* Round X to nearest integer value, rounding halfway cases to even. */ |

346 | __MATHCALLX (roundeven,, (_Mdouble_ __x), (__const__)); |

347 | |

348 | /* Round X to nearest signed integer value, not raising inexact, with |

349 | control of rounding direction and width of result. */ |

350 | __MATHDECL (__intmax_t, fromfp,, (_Mdouble_ __x, int __round, |

351 | unsigned int __width)); |

352 | |

353 | /* Round X to nearest unsigned integer value, not raising inexact, |

354 | with control of rounding direction and width of result. */ |

355 | __MATHDECL (__uintmax_t, ufromfp,, (_Mdouble_ __x, int __round, |

356 | unsigned int __width)); |

357 | |

358 | /* Round X to nearest signed integer value, raising inexact for |

359 | non-integers, with control of rounding direction and width of |

360 | result. */ |

361 | __MATHDECL (__intmax_t, fromfpx,, (_Mdouble_ __x, int __round, |

362 | unsigned int __width)); |

363 | |

364 | /* Round X to nearest unsigned integer value, raising inexact for |

365 | non-integers, with control of rounding direction and width of |

366 | result. */ |

367 | __MATHDECL (__uintmax_t, ufromfpx,, (_Mdouble_ __x, int __round, |

368 | unsigned int __width)); |

369 | |

370 | /* Return value with maximum magnitude. */ |

371 | __MATHCALLX (fmaxmag,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); |

372 | |

373 | /* Return value with minimum magnitude. */ |

374 | __MATHCALLX (fminmag,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); |

375 | |

376 | /* Total order operation. */ |

377 | __MATHDECL_1 (int, totalorder,, (_Mdouble_ __x, _Mdouble_ __y)) |

378 | __attribute__ ((__const__)); |

379 | |

380 | /* Total order operation on absolute values. */ |

381 | __MATHDECL_1 (int, totalordermag,, (_Mdouble_ __x, _Mdouble_ __y)) |

382 | __attribute__ ((__const__)); |

383 | |

384 | /* Canonicalize floating-point representation. */ |

385 | __MATHDECL_1 (int, canonicalize,, (_Mdouble_ *__cx, const _Mdouble_ *__x)); |

386 | |

387 | /* Get NaN payload. */ |

388 | __MATHCALL (getpayload,, (const _Mdouble_ *__x)); |

389 | |

390 | /* Set quiet NaN payload. */ |

391 | __MATHDECL_1 (int, setpayload,, (_Mdouble_ *__x, _Mdouble_ __payload)); |

392 | |

393 | /* Set signaling NaN payload. */ |

394 | __MATHDECL_1 (int, setpayloadsig,, (_Mdouble_ *__x, _Mdouble_ __payload)); |

395 | #endif |

396 | |

397 | #if (defined __USE_MISC || (defined __USE_XOPEN_EXTENDED \ |

398 | && __MATH_DECLARING_DOUBLE \ |

399 | && !defined __USE_XOPEN2K8)) \ |

400 | && !__MATH_DECLARING_FLOATN |

401 | /* Return X times (2 to the Nth power). */ |

402 | __MATHCALL (scalb,, (_Mdouble_ __x, _Mdouble_ __n)); |

403 | #endif |

404 |