/src/core/stdc/math.d

http://github.com/AlexeyProkhin/druntime · D · 1096 lines · 829 code · 193 blank · 74 comment · 41 complexity · 38ca15b10c94274bfa98e912ba234d6d MD5 · raw file

  1. /**
  2. * D header file for C99.
  3. *
  4. * Copyright: Copyright Sean Kelly 2005 - 2012.
  5. * License: Distributed under the
  6. * $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
  7. * (See accompanying file LICENSE)
  8. * Authors: Sean Kelly
  9. * Source: $(DRUNTIMESRC core/stdc/_math.d)
  10. */
  11. module core.stdc.math;
  12. private import core.stdc.config;
  13. extern (C):
  14. @trusted: // All functions here operate on floating point and integer values only.
  15. nothrow:
  16. pure:
  17. alias float float_t;
  18. alias double double_t;
  19. enum double HUGE_VAL = double.infinity;
  20. enum double HUGE_VALF = float.infinity;
  21. enum double HUGE_VALL = real.infinity;
  22. enum float INFINITY = float.infinity;
  23. enum float NAN = float.nan;
  24. enum int FP_ILOGB0 = int.min;
  25. enum int FP_ILOGBNAN = int.min;
  26. enum int MATH_ERRNO = 1;
  27. enum int MATH_ERREXCEPT = 2;
  28. enum int math_errhandling = MATH_ERRNO | MATH_ERREXCEPT;
  29. version( none )
  30. {
  31. //
  32. // these functions are all macros in C
  33. //
  34. //int fpclassify(real-floating x);
  35. int fpclassify(float x);
  36. int fpclassify(double x);
  37. int fpclassify(real x);
  38. //int isfinite(real-floating x);
  39. int isfinite(float x);
  40. int isfinite(double x);
  41. int isfinite(real x);
  42. //int isinf(real-floating x);
  43. int isinf(float x);
  44. int isinf(double x);
  45. int isinf(real x);
  46. //int isnan(real-floating x);
  47. int isnan(float x);
  48. int isnan(double x);
  49. int isnan(real x);
  50. //int isnormal(real-floating x);
  51. int isnormal(float x);
  52. int isnormal(double x);
  53. int isnormal(real x);
  54. //int signbit(real-floating x);
  55. int signbit(float x);
  56. int signbit(double x);
  57. int signbit(real x);
  58. //int isgreater(real-floating x, real-floating y);
  59. int isgreater(float x, float y);
  60. int isgreater(double x, double y);
  61. int isgreater(real x, real y);
  62. //int isgreaterequal(real-floating x, real-floating y);
  63. int isgreaterequal(float x, float y);
  64. int isgreaterequal(double x, double y);
  65. int isgreaterequal(real x, real y);
  66. //int isless(real-floating x, real-floating y);
  67. int isless(float x, float y);
  68. int isless(double x, double y);
  69. int isless(real x, real y);
  70. //int islessequal(real-floating x, real-floating y);
  71. int islessequal(float x, float y);
  72. int islessequal(double x, double y);
  73. int islessequal(real x, real y);
  74. //int islessgreater(real-floating x, real-floating y);
  75. int islessgreater(float x, float y);
  76. int islessgreater(double x, double y);
  77. int islessgreater(real x, real y);
  78. //int isunordered(real-floating x, real-floating y);
  79. int isunordered(float x, float y);
  80. int isunordered(double x, double y);
  81. int isunordered(real x, real y);
  82. }
  83. version( DigitalMars )
  84. {
  85. version( Win32 )
  86. version = DigitalMarsWin32;
  87. version( Win64 )
  88. version = DigitalMarsWin64; // just to get it to compile for the moment - fix later
  89. }
  90. version( DigitalMarsWin32 )
  91. {
  92. enum
  93. {
  94. FP_NANS = 0,
  95. FP_NANQ = 1,
  96. FP_INFINITE = 2,
  97. FP_NORMAL = 3,
  98. FP_SUBNORMAL = 4,
  99. FP_ZERO = 5,
  100. FP_NAN = FP_NANQ,
  101. FP_EMPTY = 6,
  102. FP_UNSUPPORTED = 7,
  103. }
  104. enum
  105. {
  106. FP_FAST_FMA = 0,
  107. FP_FAST_FMAF = 0,
  108. FP_FAST_FMAL = 0,
  109. }
  110. uint __fpclassify_f(float x);
  111. uint __fpclassify_d(double x);
  112. uint __fpclassify_ld(real x);
  113. extern (D)
  114. {
  115. //int fpclassify(real-floating x);
  116. int fpclassify(float x) { return __fpclassify_f(x); }
  117. int fpclassify(double x) { return __fpclassify_d(x); }
  118. int fpclassify(real x)
  119. {
  120. return (real.sizeof == double.sizeof)
  121. ? __fpclassify_d(x)
  122. : __fpclassify_ld(x);
  123. }
  124. //int isfinite(real-floating x);
  125. int isfinite(float x) { return fpclassify(x) >= FP_NORMAL; }
  126. int isfinite(double x) { return fpclassify(x) >= FP_NORMAL; }
  127. int isfinite(real x) { return fpclassify(x) >= FP_NORMAL; }
  128. //int isinf(real-floating x);
  129. int isinf(float x) { return fpclassify(x) == FP_INFINITE; }
  130. int isinf(double x) { return fpclassify(x) == FP_INFINITE; }
  131. int isinf(real x) { return fpclassify(x) == FP_INFINITE; }
  132. //int isnan(real-floating x);
  133. int isnan(float x) { return fpclassify(x) <= FP_NANQ; }
  134. int isnan(double x) { return fpclassify(x) <= FP_NANQ; }
  135. int isnan(real x) { return fpclassify(x) <= FP_NANQ; }
  136. //int isnormal(real-floating x);
  137. int isnormal(float x) { return fpclassify(x) == FP_NORMAL; }
  138. int isnormal(double x) { return fpclassify(x) == FP_NORMAL; }
  139. int isnormal(real x) { return fpclassify(x) == FP_NORMAL; }
  140. //int signbit(real-floating x);
  141. int signbit(float x) { return (cast(short*)&(x))[1] & 0x8000; }
  142. int signbit(double x) { return (cast(short*)&(x))[3] & 0x8000; }
  143. int signbit(real x)
  144. {
  145. return (real.sizeof == double.sizeof)
  146. ? (cast(short*)&(x))[3] & 0x8000
  147. : (cast(short*)&(x))[4] & 0x8000;
  148. }
  149. }
  150. }
  151. else version( DigitalMarsWin64 )
  152. {
  153. enum
  154. {
  155. _FPCLASS_SNAN = 1,
  156. _FPCLASS_QNAN = 2,
  157. _FPCLASS_NINF = 4,
  158. _FPCLASS_NN = 8,
  159. _FPCLASS_ND = 0x10,
  160. _FPCLASS_NZ = 0x20,
  161. _FPCLASS_PZ = 0x40,
  162. _FPCLASS_PD = 0x80,
  163. _FPCLASS_PN = 0x100,
  164. _FPCLASS_PINF = 0x200,
  165. }
  166. float _copysignf(float x, float s);
  167. float _chgsignf(float x);
  168. int _finitef(float x);
  169. int _isnanf(float x);
  170. int _fpclassf(float x);
  171. double _copysign(double x, double s);
  172. double _chgsign(double x);
  173. int _finite(double x);
  174. int _isnan(double x);
  175. int _fpclass(double x);
  176. extern(D)
  177. {
  178. int isnan(float x) { return _isnanf(x); }
  179. int isnan(double x) { return _isnan(x); }
  180. int isnan(real x) { return _isnan(x); }
  181. }
  182. }
  183. else version( linux )
  184. {
  185. enum
  186. {
  187. FP_NAN,
  188. FP_INFINITE,
  189. FP_ZERO,
  190. FP_SUBNORMAL,
  191. FP_NORMAL,
  192. }
  193. enum
  194. {
  195. FP_FAST_FMA = 0,
  196. FP_FAST_FMAF = 0,
  197. FP_FAST_FMAL = 0,
  198. }
  199. int __fpclassifyf(float x);
  200. int __fpclassify(double x);
  201. int __fpclassifyl(real x);
  202. int __finitef(float x);
  203. int __finite(double x);
  204. int __finitel(real x);
  205. int __isinff(float x);
  206. int __isinf(double x);
  207. int __isinfl(real x);
  208. int __isnanf(float x);
  209. int __isnan(double x);
  210. int __isnanl(real x);
  211. int __signbitf(float x);
  212. int __signbit(double x);
  213. int __signbitl(real x);
  214. extern (D)
  215. {
  216. //int fpclassify(real-floating x);
  217. int fpclassify(float x) { return __fpclassifyf(x); }
  218. int fpclassify(double x) { return __fpclassify(x); }
  219. int fpclassify(real x)
  220. {
  221. return (real.sizeof == double.sizeof)
  222. ? __fpclassify(x)
  223. : __fpclassifyl(x);
  224. }
  225. //int isfinite(real-floating x);
  226. int isfinite(float x) { return __finitef(x); }
  227. int isfinite(double x) { return __finite(x); }
  228. int isfinite(real x)
  229. {
  230. return (real.sizeof == double.sizeof)
  231. ? __finite(x)
  232. : __finitel(x);
  233. }
  234. //int isinf(real-floating x);
  235. int isinf(float x) { return __isinff(x); }
  236. int isinf(double x) { return __isinf(x); }
  237. int isinf(real x)
  238. {
  239. return (real.sizeof == double.sizeof)
  240. ? __isinf(x)
  241. : __isinfl(x);
  242. }
  243. //int isnan(real-floating x);
  244. int isnan(float x) { return __isnanf(x); }
  245. int isnan(double x) { return __isnan(x); }
  246. int isnan(real x)
  247. {
  248. return (real.sizeof == double.sizeof)
  249. ? __isnan(x)
  250. : __isnanl(x);
  251. }
  252. //int isnormal(real-floating x);
  253. int isnormal(float x) { return fpclassify(x) == FP_NORMAL; }
  254. int isnormal(double x) { return fpclassify(x) == FP_NORMAL; }
  255. int isnormal(real x) { return fpclassify(x) == FP_NORMAL; }
  256. //int signbit(real-floating x);
  257. int signbit(float x) { return __signbitf(x); }
  258. int signbit(double x) { return __signbit(x); }
  259. int signbit(real x)
  260. {
  261. return (real.sizeof == double.sizeof)
  262. ? __signbit(x)
  263. : __signbitl(x);
  264. }
  265. }
  266. }
  267. else version( MinGW )
  268. {
  269. enum
  270. {
  271. FP_NAN = 0x0100,
  272. FP_NORMAL = 0x0400,
  273. FP_INFINITE = FP_NAN | FP_NORMAL,
  274. FP_ZERO = 0x0400,
  275. FP_SUBNORMAL = FP_NORMAL | FP_ZERO
  276. }
  277. int __fpclassifyf(float x);
  278. int __fpclassify(double x);
  279. int __fpclassifyl(real x);
  280. int __isnanf(float x);
  281. int __isnan(double x);
  282. int __isnanl(real x);
  283. int __signbitf(float x);
  284. int __signbit(double x);
  285. int __signbitl(real x);
  286. extern (D)
  287. {
  288. //int fpclassify(real-floating x);
  289. int fpclassify(float x) { return __fpclassifyf(x); }
  290. int fpclassify(double x) { return __fpclassify(x); }
  291. int fpclassify(real x)
  292. {
  293. return (real.sizeof == double.sizeof)
  294. ? __fpclassify(x)
  295. : __fpclassifyl(x);
  296. }
  297. //int isfinite(real-floating x);
  298. int isfinite(float x) { return (fpclassify(x) & FP_NORMAL) == 0; }
  299. int isfinite(double x) { return (fpclassify(x) & FP_NORMAL) == 0; }
  300. int isfinite(real x) { return (fpclassify(x) & FP_NORMAL) == 0; }
  301. //int isinf(real-floating x);
  302. int isinf(float x) { return fpclassify(x) == FP_INFINITE; }
  303. int isinf(double x) { return fpclassify(x) == FP_INFINITE; }
  304. int isinf(real x) { return fpclassify(x) == FP_INFINITE; }
  305. //int isnan(real-floating x);
  306. int isnan(float x) { return __isnanf(x); }
  307. int isnan(double x) { return __isnan(x); }
  308. int isnan(real x)
  309. {
  310. return (real.sizeof == double.sizeof)
  311. ? __isnan(x)
  312. : __isnanl(x);
  313. }
  314. //int isnormal(real-floating x);
  315. int isnormal(float x) { return fpclassify(x) == FP_NORMAL; }
  316. int isnormal(double x) { return fpclassify(x) == FP_NORMAL; }
  317. int isnormal(real x) { return fpclassify(x) == FP_NORMAL; }
  318. //int signbit(real-floating x);
  319. int signbit(float x) { return __signbitf(x); }
  320. int signbit(double x) { return __signbit(x); }
  321. int signbit(real x)
  322. {
  323. return (real.sizeof == double.sizeof)
  324. ? __signbit(x)
  325. : __signbitl(x);
  326. }
  327. }
  328. }
  329. else version( OSX )
  330. {
  331. enum
  332. {
  333. FP_NAN = 1,
  334. FP_INFINITE = 2,
  335. FP_ZERO = 3,
  336. FP_NORMAL = 4,
  337. FP_SUBNORMAL = 5,
  338. FP_SUPERNORMAL = 6,
  339. }
  340. enum
  341. {
  342. FP_FAST_FMA = 0,
  343. FP_FAST_FMAF = 0,
  344. FP_FAST_FMAL = 0,
  345. }
  346. int __fpclassifyf(float x);
  347. int __fpclassifyd(double x);
  348. int __fpclassify(real x);
  349. int __isfinitef(float x);
  350. int __isfinited(double x);
  351. int __isfinite(real x);
  352. int __isinff(float x);
  353. int __isinfd(double x);
  354. int __isinf(real x);
  355. int __isnanf(float x);
  356. int __isnand(double x);
  357. int __isnan(real x);
  358. int __signbitf(float x);
  359. int __signbitd(double x);
  360. int __signbitl(real x);
  361. extern (D)
  362. {
  363. //int fpclassify(real-floating x);
  364. int fpclassify(float x) { return __fpclassifyf(x); }
  365. int fpclassify(double x) { return __fpclassifyd(x); }
  366. int fpclassify(real x)
  367. {
  368. return (real.sizeof == double.sizeof)
  369. ? __fpclassifyd(x)
  370. : __fpclassify(x);
  371. }
  372. //int isfinite(real-floating x);
  373. int isfinite(float x) { return __isfinitef(x); }
  374. int isfinite(double x) { return __isfinited(x); }
  375. int isfinite(real x)
  376. {
  377. return (real.sizeof == double.sizeof)
  378. ? __isfinited(x)
  379. : __isfinite(x);
  380. }
  381. //int isinf(real-floating x);
  382. int isinf(float x) { return __isinff(x); }
  383. int isinf(double x) { return __isinfd(x); }
  384. int isinf(real x)
  385. {
  386. return (real.sizeof == double.sizeof)
  387. ? __isinfd(x)
  388. : __isinf(x);
  389. }
  390. //int isnan(real-floating x);
  391. int isnan(float x) { return __isnanf(x); }
  392. int isnan(double x) { return __isnand(x); }
  393. int isnan(real x)
  394. {
  395. return (real.sizeof == double.sizeof)
  396. ? __isnand(x)
  397. : __isnan(x);
  398. }
  399. //int isnormal(real-floating x);
  400. int isnormal(float x) { return fpclassify(x) == FP_NORMAL; }
  401. int isnormal(double x) { return fpclassify(x) == FP_NORMAL; }
  402. int isnormal(real x) { return fpclassify(x) == FP_NORMAL; }
  403. //int signbit(real-floating x);
  404. int signbit(float x) { return __signbitf(x); }
  405. int signbit(double x) { return __signbitd(x); }
  406. int signbit(real x)
  407. {
  408. return (real.sizeof == double.sizeof)
  409. ? __signbitd(x)
  410. : __signbitl(x);
  411. }
  412. }
  413. }
  414. else version( FreeBSD )
  415. {
  416. enum
  417. {
  418. FP_INFINITE = 0x01,
  419. FP_NAN = 0x02,
  420. FP_NORMAL = 0x04,
  421. FP_SUBNORMAL = 0x08,
  422. FP_ZERO = 0x10,
  423. }
  424. enum
  425. {
  426. FP_FAST_FMA = 0,
  427. FP_FAST_FMAF = 0,
  428. FP_FAST_FMAL = 0,
  429. }
  430. int __fpclassifyd(double);
  431. int __fpclassifyf(float);
  432. int __fpclassifyl(real);
  433. int __isfinitef(float);
  434. int __isfinite(double);
  435. int __isfinitel(real);
  436. int __isinff(float);
  437. int __isinfl(real);
  438. int __isnanl(real);
  439. int __isnormalf(float);
  440. int __isnormal(double);
  441. int __isnormall(real);
  442. int __signbit(double);
  443. int __signbitf(float);
  444. int __signbitl(real);
  445. extern (D)
  446. {
  447. //int fpclassify(real-floating x);
  448. int fpclassify(float x) { return __fpclassifyf(x); }
  449. int fpclassify(double x) { return __fpclassifyd(x); }
  450. int fpclassify(real x) { return __fpclassifyl(x); }
  451. //int isfinite(real-floating x);
  452. int isfinite(float x) { return __isfinitef(x); }
  453. int isfinite(double x) { return __isfinite(x); }
  454. int isfinite(real x) { return __isfinitel(x); }
  455. //int isinf(real-floating x);
  456. int isinf(float x) { return __isinff(x); }
  457. int isinf(double x) { return __isinfl(x); }
  458. int isinf(real x) { return __isinfl(x); }
  459. //int isnan(real-floating x);
  460. int isnan(float x) { return __isnanl(x); }
  461. int isnan(double x) { return __isnanl(x); }
  462. int isnan(real x) { return __isnanl(x); }
  463. //int isnormal(real-floating x);
  464. int isnormal(float x) { return __isnormalf(x); }
  465. int isnormal(double x) { return __isnormal(x); }
  466. int isnormal(real x) { return __isnormall(x); }
  467. //int signbit(real-floating x);
  468. int signbit(float x) { return __signbitf(x); }
  469. int signbit(double x) { return __signbit(x); }
  470. int signbit(real x) { return __signbit(x); }
  471. }
  472. }
  473. extern (D)
  474. {
  475. //int isgreater(real-floating x, real-floating y);
  476. int isgreater(float x, float y) { return !(x !> y); }
  477. int isgreater(double x, double y) { return !(x !> y); }
  478. int isgreater(real x, real y) { return !(x !> y); }
  479. //int isgreaterequal(real-floating x, real-floating y);
  480. int isgreaterequal(float x, float y) { return !(x !>= y); }
  481. int isgreaterequal(double x, double y) { return !(x !>= y); }
  482. int isgreaterequal(real x, real y) { return !(x !>= y); }
  483. //int isless(real-floating x, real-floating y);
  484. int isless(float x, float y) { return !(x !< y); }
  485. int isless(double x, double y) { return !(x !< y); }
  486. int isless(real x, real y) { return !(x !< y); }
  487. //int islessequal(real-floating x, real-floating y);
  488. int islessequal(float x, float y) { return !(x !<= y); }
  489. int islessequal(double x, double y) { return !(x !<= y); }
  490. int islessequal(real x, real y) { return !(x !<= y); }
  491. //int islessgreater(real-floating x, real-floating y);
  492. int islessgreater(float x, float y) { return !(x !<> y); }
  493. int islessgreater(double x, double y) { return !(x !<> y); }
  494. int islessgreater(real x, real y) { return !(x !<> y); }
  495. //int isunordered(real-floating x, real-floating y);
  496. int isunordered(float x, float y) { return (x !<>= y); }
  497. int isunordered(double x, double y) { return (x !<>= y); }
  498. int isunordered(real x, real y) { return (x !<>= y); }
  499. }
  500. /* NOTE: freebsd < 8-CURRENT doesn't appear to support *l, but we can
  501. * approximate.
  502. * A lot of them were added in 8.0-RELEASE, and so a lot of these workarounds
  503. * should then be removed.
  504. */
  505. // NOTE: FreeBSD 8.0-RELEASE doesn't support log2* nor these *l functions:
  506. // acoshl, asinhl, atanhl, coshl, sinhl, tanhl, cbrtl, powl, expl,
  507. // expm1l, logl, log1pl, log10l, erfcl, erfl, lgammal, tgammal;
  508. // but we can approximate.
  509. version( FreeBSD )
  510. {
  511. version (none) // < 8-CURRENT
  512. {
  513. real acosl(real x) { return acos(x); }
  514. real asinl(real x) { return asin(x); }
  515. real atanl(real x) { return atan(x); }
  516. real atan2l(real y, real x) { return atan2(y, x); }
  517. real cosl(real x) { return cos(x); }
  518. real sinl(real x) { return sin(x); }
  519. real tanl(real x) { return tan(x); }
  520. real exp2l(real x) { return exp2(x); }
  521. real frexpl(real value, int* exp) { return frexp(value, exp); }
  522. int ilogbl(real x) { return ilogb(x); }
  523. real ldexpl(real x, int exp) { return ldexp(x, exp); }
  524. real logbl(real x) { return logb(x); }
  525. //real modfl(real value, real *iptr); // nontrivial conversion
  526. real scalbnl(real x, int n) { return scalbn(x, n); }
  527. real scalblnl(real x, c_long n) { return scalbln(x, n); }
  528. real fabsl(real x) { return fabs(x); }
  529. real hypotl(real x, real y) { return hypot(x, y); }
  530. real sqrtl(real x) { return sqrt(x); }
  531. real ceill(real x) { return ceil(x); }
  532. real floorl(real x) { return floor(x); }
  533. real nearbyintl(real x) { return nearbyint(x); }
  534. real rintl(real x) { return rint(x); }
  535. c_long lrintl(real x) { return lrint(x); }
  536. real roundl(real x) { return round(x); }
  537. c_long lroundl(real x) { return lround(x); }
  538. long llroundl(real x) { return llround(x); }
  539. real truncl(real x) { return trunc(x); }
  540. real fmodl(real x, real y) { return fmod(x, y); }
  541. real remainderl(real x, real y) { return remainder(x, y); }
  542. real remquol(real x, real y, int* quo) { return remquo(x, y, quo); }
  543. real copysignl(real x, real y) { return copysign(x, y); }
  544. // double nan(char* tagp);
  545. // float nanf(char* tagp);
  546. // real nanl(char* tagp);
  547. real nextafterl(real x, real y) { return nextafter(x, y); }
  548. real nexttowardl(real x, real y) { return nexttoward(x, y); }
  549. real fdiml(real x, real y) { return fdim(x, y); }
  550. real fmaxl(real x, real y) { return fmax(x, y); }
  551. real fminl(real x, real y) { return fmin(x, y); }
  552. real fmal(real x, real y, real z) { return fma(x, y, z); }
  553. }
  554. else
  555. {
  556. real acosl(real x);
  557. real asinl(real x);
  558. real atanl(real x);
  559. real atan2l(real y, real x);
  560. real cosl(real x);
  561. real sinl(real x);
  562. real tanl(real x);
  563. real exp2l(real x);
  564. real frexpl(real value, int* exp);
  565. int ilogbl(real x);
  566. real ldexpl(real x, int exp);
  567. real logbl(real x);
  568. real modfl(real value, real *iptr);
  569. real scalbnl(real x, int n);
  570. real scalblnl(real x, c_long n);
  571. real fabsl(real x);
  572. real hypotl(real x, real y);
  573. real sqrtl(real x);
  574. real ceill(real x);
  575. real floorl(real x);
  576. real nearbyintl(real x);
  577. real rintl(real x);
  578. c_long lrintl(real x);
  579. real roundl(real x);
  580. c_long lroundl(real x);
  581. long llroundl(real x);
  582. real truncl(real x);
  583. real fmodl(real x, real y);
  584. real remainderl(real x, real y);
  585. real remquol(real x, real y, int* quo);
  586. real copysignl(real x, real y);
  587. double nan(char* tagp);
  588. float nanf(char* tagp);
  589. real nanl(char* tagp);
  590. real nextafterl(real x, real y);
  591. real nexttowardl(real x, real y);
  592. real fdiml(real x, real y);
  593. real fmaxl(real x, real y);
  594. real fminl(real x, real y);
  595. real fmal(real x, real y, real z);
  596. }
  597. double acos(double x);
  598. float acosf(float x);
  599. double asin(double x);
  600. float asinf(float x);
  601. double atan(double x);
  602. float atanf(float x);
  603. double atan2(double y, double x);
  604. float atan2f(float y, float x);
  605. double cos(double x);
  606. float cosf(float x);
  607. double sin(double x);
  608. float sinf(float x);
  609. double tan(double x);
  610. float tanf(float x);
  611. double acosh(double x);
  612. float acoshf(float x);
  613. real acoshl(real x) { return acosh(x); }
  614. double asinh(double x);
  615. float asinhf(float x);
  616. real asinhl(real x) { return asinh(x); }
  617. double atanh(double x);
  618. float atanhf(float x);
  619. real atanhl(real x) { return atanh(x); }
  620. double cosh(double x);
  621. float coshf(float x);
  622. real coshl(real x) { return cosh(x); }
  623. double sinh(double x);
  624. float sinhf(float x);
  625. real sinhl(real x) { return sinh(x); }
  626. double tanh(double x);
  627. float tanhf(float x);
  628. real tanhl(real x) { return tanh(x); }
  629. double exp(double x);
  630. float expf(float x);
  631. real expl(real x) { return exp(x); }
  632. double exp2(double x);
  633. float exp2f(float x);
  634. double expm1(double x);
  635. float expm1f(float x);
  636. real expm1l(real x) { return expm1(x); }
  637. double frexp(double value, int* exp);
  638. float frexpf(float value, int* exp);
  639. int ilogb(double x);
  640. int ilogbf(float x);
  641. double ldexp(double x, int exp);
  642. float ldexpf(float x, int exp);
  643. double log(double x);
  644. float logf(float x);
  645. real logl(real x) { return log(x); }
  646. double log10(double x);
  647. float log10f(float x);
  648. real log10l(real x) { return log10(x); }
  649. double log1p(double x);
  650. float log1pf(float x);
  651. real log1pl(real x) { return log1p(x); }
  652. private enum real ONE_LN2 = 1 / 0x1.62e42fefa39ef358p-1L;
  653. double log2(double x) { return log(x) * ONE_LN2; }
  654. float log2f(float x) { return logf(x) * ONE_LN2; }
  655. real log2l(real x) { return logl(x) * ONE_LN2; }
  656. double logb(double x);
  657. float logbf(float x);
  658. double modf(double value, double* iptr);
  659. float modff(float value, float* iptr);
  660. double scalbn(double x, int n);
  661. float scalbnf(float x, int n);
  662. double scalbln(double x, c_long n);
  663. float scalblnf(float x, c_long n);
  664. double cbrt(double x);
  665. float cbrtf(float x);
  666. real cbrtl(real x) { return cbrt(x); }
  667. double fabs(double x);
  668. float fabsf(float x);
  669. double hypot(double x, double y);
  670. float hypotf(float x, float y);
  671. double pow(double x, double y);
  672. float powf(float x, float y);
  673. real powl(real x, real y) { return pow(x, y); }
  674. double sqrt(double x);
  675. float sqrtf(float x);
  676. double erf(double x);
  677. float erff(float x);
  678. real erfl(real x) { return erf(x); }
  679. double erfc(double x);
  680. float erfcf(float x);
  681. real erfcl(real x) { return erfc(x); }
  682. double lgamma(double x);
  683. float lgammaf(float x);
  684. real lgammal(real x) { return lgamma(x); }
  685. double tgamma(double x);
  686. float tgammaf(float x);
  687. real tgammal(real x) { return tgamma(x); }
  688. double ceil(double x);
  689. float ceilf(float x);
  690. double floor(double x);
  691. float floorf(float x);
  692. double nearbyint(double x);
  693. float nearbyintf(float x);
  694. double rint(double x);
  695. float rintf(float x);
  696. c_long lrint(double x);
  697. c_long lrintf(float x);
  698. long llrint(double x);
  699. long llrintf(float x);
  700. long llrintl(real x) { return llrint(x); }
  701. double round(double x);
  702. float roundf(float x);
  703. c_long lround(double x);
  704. c_long lroundf(float x);
  705. long llround(double x);
  706. long llroundf(float x);
  707. double trunc(double x);
  708. float truncf(float x);
  709. double fmod(double x, double y);
  710. float fmodf(float x, float y);
  711. double remainder(double x, double y);
  712. float remainderf(float x, float y);
  713. double remquo(double x, double y, int* quo);
  714. float remquof(float x, float y, int* quo);
  715. double copysign(double x, double y);
  716. float copysignf(float x, float y);
  717. double nextafter(double x, double y);
  718. float nextafterf(float x, float y);
  719. double nexttoward(double x, real y);
  720. float nexttowardf(float x, real y);
  721. double fdim(double x, double y);
  722. float fdimf(float x, float y);
  723. double fmax(double x, double y);
  724. float fmaxf(float x, float y);
  725. double fmin(double x, double y);
  726. float fminf(float x, float y);
  727. double fma(double x, double y, double z);
  728. float fmaf(float x, float y, float z);
  729. }
  730. else
  731. {
  732. double acos(double x);
  733. float acosf(float x);
  734. real acosl(real x);
  735. double asin(double x);
  736. float asinf(float x);
  737. real asinl(real x);
  738. double atan(double x);
  739. float atanf(float x);
  740. real atanl(real x);
  741. double atan2(double y, double x);
  742. float atan2f(float y, float x);
  743. real atan2l(real y, real x);
  744. double cos(double x);
  745. float cosf(float x);
  746. real cosl(real x);
  747. double sin(double x);
  748. float sinf(float x);
  749. real sinl(real x);
  750. double tan(double x);
  751. float tanf(float x);
  752. real tanl(real x);
  753. double acosh(double x);
  754. float acoshf(float x);
  755. real acoshl(real x);
  756. double asinh(double x);
  757. float asinhf(float x);
  758. real asinhl(real x);
  759. double atanh(double x);
  760. float atanhf(float x);
  761. real atanhl(real x);
  762. double cosh(double x);
  763. float coshf(float x);
  764. real coshl(real x);
  765. double sinh(double x);
  766. float sinhf(float x);
  767. real sinhl(real x);
  768. double tanh(double x);
  769. float tanhf(float x);
  770. real tanhl(real x);
  771. double exp(double x);
  772. float expf(float x);
  773. real expl(real x);
  774. double exp2(double x);
  775. float exp2f(float x);
  776. real exp2l(real x);
  777. double expm1(double x);
  778. float expm1f(float x);
  779. real expm1l(real x);
  780. double frexp(double value, int* exp);
  781. float frexpf(float value, int* exp);
  782. real frexpl(real value, int* exp);
  783. int ilogb(double x);
  784. int ilogbf(float x);
  785. int ilogbl(real x);
  786. double ldexp(double x, int exp);
  787. float ldexpf(float x, int exp);
  788. real ldexpl(real x, int exp);
  789. double log(double x);
  790. float logf(float x);
  791. real logl(real x);
  792. double log10(double x);
  793. float log10f(float x);
  794. real log10l(real x);
  795. double log1p(double x);
  796. float log1pf(float x);
  797. real log1pl(real x);
  798. double log2(double x);
  799. float log2f(float x);
  800. real log2l(real x);
  801. double logb(double x);
  802. float logbf(float x);
  803. real logbl(real x);
  804. double modf(double value, double* iptr);
  805. float modff(float value, float* iptr);
  806. real modfl(real value, real *iptr);
  807. double scalbn(double x, int n);
  808. float scalbnf(float x, int n);
  809. real scalbnl(real x, int n);
  810. double scalbln(double x, c_long n);
  811. float scalblnf(float x, c_long n);
  812. real scalblnl(real x, c_long n);
  813. double cbrt(double x);
  814. float cbrtf(float x);
  815. real cbrtl(real x);
  816. double fabs(double x);
  817. float fabsf(float x);
  818. real fabsl(real x);
  819. double hypot(double x, double y);
  820. float hypotf(float x, float y);
  821. real hypotl(real x, real y);
  822. double pow(double x, double y);
  823. float powf(float x, float y);
  824. real powl(real x, real y);
  825. double sqrt(double x);
  826. float sqrtf(float x);
  827. real sqrtl(real x);
  828. double erf(double x);
  829. float erff(float x);
  830. real erfl(real x);
  831. double erfc(double x);
  832. float erfcf(float x);
  833. real erfcl(real x);
  834. double lgamma(double x);
  835. float lgammaf(float x);
  836. real lgammal(real x);
  837. double tgamma(double x);
  838. float tgammaf(float x);
  839. real tgammal(real x);
  840. double ceil(double x);
  841. float ceilf(float x);
  842. real ceill(real x);
  843. double floor(double x);
  844. float floorf(float x);
  845. real floorl(real x);
  846. double nearbyint(double x);
  847. float nearbyintf(float x);
  848. real nearbyintl(real x);
  849. double rint(double x);
  850. float rintf(float x);
  851. real rintl(real x);
  852. c_long lrint(double x);
  853. c_long lrintf(float x);
  854. c_long lrintl(real x);
  855. long llrint(double x);
  856. long llrintf(float x);
  857. long llrintl(real x);
  858. double round(double x);
  859. float roundf(float x);
  860. real roundl(real x);
  861. c_long lround(double x);
  862. c_long lroundf(float x);
  863. c_long lroundl(real x);
  864. long llround(double x);
  865. long llroundf(float x);
  866. long llroundl(real x);
  867. double trunc(double x);
  868. float truncf(float x);
  869. real truncl(real x);
  870. double fmod(double x, double y);
  871. float fmodf(float x, float y);
  872. real fmodl(real x, real y);
  873. double remainder(double x, double y);
  874. float remainderf(float x, float y);
  875. real remainderl(real x, real y);
  876. double remquo(double x, double y, int* quo);
  877. float remquof(float x, float y, int* quo);
  878. real remquol(real x, real y, int* quo);
  879. double copysign(double x, double y);
  880. float copysignf(float x, float y);
  881. real copysignl(real x, real y);
  882. double nan(char* tagp);
  883. float nanf(char* tagp);
  884. real nanl(char* tagp);
  885. double nextafter(double x, double y);
  886. float nextafterf(float x, float y);
  887. real nextafterl(real x, real y);
  888. double nexttoward(double x, real y);
  889. float nexttowardf(float x, real y);
  890. real nexttowardl(real x, real y);
  891. double fdim(double x, double y);
  892. float fdimf(float x, float y);
  893. real fdiml(real x, real y);
  894. double fmax(double x, double y);
  895. float fmaxf(float x, float y);
  896. real fmaxl(real x, real y);
  897. double fmin(double x, double y);
  898. float fminf(float x, float y);
  899. real fminl(real x, real y);
  900. double fma(double x, double y, double z);
  901. float fmaf(float x, float y, float z);
  902. real fmal(real x, real y, real z);
  903. }