Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2536 lines
77 KiB

  1. /*
  2. File: fp.h
  3. Contains: FPCE Floating-Point Definitions and Declarations.
  4. Version: QuickTime 7.3
  5. Copyright: (c) 2007 (c) 1987-2001 by Apple Computer, Inc., all rights reserved.
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://developer.apple.com/bugreporter/
  9. */
  10. #ifndef __FP__
  11. #define __FP__
  12. #ifndef __CONDITIONALMACROS__
  13. #include <ConditionalMacros.h>
  14. #endif
  15. #ifndef __MACTYPES__
  16. #include <MacTypes.h>
  17. #endif
  18. /********************************************************************************
  19. * *
  20. * A collection of numerical functions designed to facilitate a wide *
  21. * range of numerical programming as required by C9X. *
  22. * *
  23. * The <fp.h> declares many functions in support of numerical programming. *
  24. * It provides a superset of <math.h> and <SANE.h> functions. Some *
  25. * functionality previously found in <SANE.h> and not in the FPCE <fp.h> *
  26. * can be found in this <fp.h> under the heading "__NOEXTENSIONS__". *
  27. * *
  28. * All of these functions are IEEE 754 aware and treat exceptions, NaNs, *
  29. * positive and negative zero and infinity consistent with the floating- *
  30. * point standard. *
  31. * *
  32. ********************************************************************************/
  33. #if PRAGMA_ONCE
  34. #pragma once
  35. #endif
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. #if PRAGMA_IMPORT
  40. #pragma import on
  41. #endif
  42. #if PRAGMA_STRUCT_ALIGN
  43. #pragma options align=mac68k
  44. #elif PRAGMA_STRUCT_PACKPUSH
  45. #pragma pack(push, 2)
  46. #elif PRAGMA_STRUCT_PACK
  47. #pragma pack(2)
  48. #endif
  49. /********************************************************************************
  50. * *
  51. * Efficient types *
  52. * *
  53. * float_t Most efficient type at least as wide as float *
  54. * double_t Most efficient type at least as wide as double *
  55. * *
  56. * CPU float_t(bits) double_t(bits) *
  57. * -------- ----------------- ----------------- *
  58. * PowerPC float(32) double(64) *
  59. * 68K long double(80/96) long double(80/96) *
  60. * x86 double(64) double(64) *
  61. * *
  62. ********************************************************************************/
  63. #if (defined(__MWERKS__) && defined(__cmath__)) || (TARGET_RT_MAC_MACHO && defined(__MATH__))
  64. /* these types were already defined in math.h */
  65. #else
  66. #if TARGET_CPU_PPC
  67. typedef float float_t;
  68. typedef double double_t;
  69. #elif TARGET_CPU_68K
  70. typedef long double float_t;
  71. typedef long double double_t;
  72. #elif TARGET_CPU_X86
  73. //typedef double float_t;
  74. typedef double double_t;
  75. #elif TARGET_CPU_MIPS
  76. typedef double float_t;
  77. typedef double double_t;
  78. #elif TARGET_CPU_ALPHA
  79. typedef double float_t;
  80. typedef double double_t;
  81. #elif TARGET_CPU_SPARC
  82. typedef double float_t;
  83. typedef double double_t;
  84. #else
  85. #error unsupported CPU
  86. #endif /* */
  87. /********************************************************************************
  88. * *
  89. * Define some constants. *
  90. * *
  91. * HUGE_VAL IEEE 754 value of infinity. *
  92. * INFINITY IEEE 754 value of infinity. *
  93. * NAN A generic NaN (Not A Number). *
  94. * DECIMAL_DIG Satisfies the constraint that the conversion from *
  95. * double to decimal and back is the identity function. *
  96. * *
  97. ********************************************************************************/
  98. #if TARGET_OS_MAC
  99. #if !TARGET_RT_MAC_MACHO
  100. #define HUGE_VAL __inf()
  101. #define INFINITY __inf()
  102. #define NAN nan("255")
  103. #endif
  104. #else
  105. //#define NAN sqrt(-1)
  106. #endif
  107. #if TARGET_CPU_PPC
  108. #define DECIMAL_DIG 17 /* does not exist for double-double */
  109. #elif TARGET_CPU_68K
  110. #define DECIMAL_DIG 21
  111. #endif
  112. #endif /* (defined(__MWERKS__) && defined(__cmath__)) || (TARGET_RT_MAC_MACHO && defined(__MATH__)) */
  113. #if TARGET_OS_MAC
  114. /* MSL or math.h already defines these */
  115. #if (!defined(__MWERKS__) || !defined(__cmath__)) && (!TARGET_RT_MAC_MACHO || !defined(__MATH__))
  116. /********************************************************************************
  117. * *
  118. * Trigonometric functions *
  119. * *
  120. * acos result is in [0,pi]. *
  121. * asin result is in [-pi/2,pi/2]. *
  122. * atan result is in [-pi/2,pi/2]. *
  123. * atan2 Computes the arc tangent of y/x in [-pi,pi] using the sign of *
  124. * both arguments to determine the quadrant of the computed value. *
  125. * *
  126. ********************************************************************************/
  127. /*
  128. * cos()
  129. *
  130. * Availability:
  131. * Non-Carbon CFM: in MathLib 1.0 and later
  132. * CarbonLib: in CarbonLib 1.0 and later
  133. * Mac OS X: in version 10.0 and later
  134. */
  135. EXTERN_API_C( double_t ) cos(double_t x);
  136. /*
  137. * sin()
  138. *
  139. * Availability:
  140. * Non-Carbon CFM: in MathLib 1.0 and later
  141. * CarbonLib: in CarbonLib 1.0 and later
  142. * Mac OS X: in version 10.0 and later
  143. */
  144. EXTERN_API_C( double_t ) sin(double_t x);
  145. /*
  146. * tan()
  147. *
  148. * Availability:
  149. * Non-Carbon CFM: in MathLib 1.0 and later
  150. * CarbonLib: in CarbonLib 1.0 and later
  151. * Mac OS X: in version 10.0 and later
  152. */
  153. EXTERN_API_C( double_t ) tan(double_t x);
  154. /*
  155. * acos()
  156. *
  157. * Availability:
  158. * Non-Carbon CFM: in MathLib 1.0 and later
  159. * CarbonLib: in CarbonLib 1.0 and later
  160. * Mac OS X: in version 10.0 and later
  161. */
  162. EXTERN_API_C( double_t ) acos(double_t x);
  163. /*
  164. * asin()
  165. *
  166. * Availability:
  167. * Non-Carbon CFM: in MathLib 1.0 and later
  168. * CarbonLib: in CarbonLib 1.0 and later
  169. * Mac OS X: in version 10.0 and later
  170. */
  171. EXTERN_API_C( double_t ) asin(double_t x);
  172. /*
  173. * atan()
  174. *
  175. * Availability:
  176. * Non-Carbon CFM: in MathLib 1.0 and later
  177. * CarbonLib: in CarbonLib 1.0 and later
  178. * Mac OS X: in version 10.0 and later
  179. */
  180. EXTERN_API_C( double_t ) atan(double_t x);
  181. /*
  182. * atan2()
  183. *
  184. * Availability:
  185. * Non-Carbon CFM: in MathLib 1.0 and later
  186. * CarbonLib: in CarbonLib 1.0 and later
  187. * Mac OS X: in version 10.0 and later
  188. */
  189. EXTERN_API_C( double_t ) atan2(double_t y, double_t x);
  190. /********************************************************************************
  191. * *
  192. * Hyperbolic functions *
  193. * *
  194. ********************************************************************************/
  195. /*
  196. * cosh()
  197. *
  198. * Availability:
  199. * Non-Carbon CFM: in MathLib 1.0 and later
  200. * CarbonLib: in CarbonLib 1.0 and later
  201. * Mac OS X: in version 10.0 and later
  202. */
  203. EXTERN_API_C( double_t ) cosh(double_t x);
  204. /*
  205. * sinh()
  206. *
  207. * Availability:
  208. * Non-Carbon CFM: in MathLib 1.0 and later
  209. * CarbonLib: in CarbonLib 1.0 and later
  210. * Mac OS X: in version 10.0 and later
  211. */
  212. EXTERN_API_C( double_t ) sinh(double_t x);
  213. /*
  214. * tanh()
  215. *
  216. * Availability:
  217. * Non-Carbon CFM: in MathLib 1.0 and later
  218. * CarbonLib: in CarbonLib 1.0 and later
  219. * Mac OS X: in version 10.0 and later
  220. */
  221. EXTERN_API_C( double_t ) tanh(double_t x);
  222. /*
  223. * acosh()
  224. *
  225. * Availability:
  226. * Non-Carbon CFM: in MathLib 1.0 and later
  227. * CarbonLib: in CarbonLib 1.0 and later
  228. * Mac OS X: in version 10.0 and later
  229. */
  230. EXTERN_API_C( double_t ) acosh(double_t x);
  231. /*
  232. * asinh()
  233. *
  234. * Availability:
  235. * Non-Carbon CFM: in MathLib 1.0 and later
  236. * CarbonLib: in CarbonLib 1.0 and later
  237. * Mac OS X: in version 10.0 and later
  238. */
  239. EXTERN_API_C( double_t ) asinh(double_t x);
  240. /*
  241. * atanh()
  242. *
  243. * Availability:
  244. * Non-Carbon CFM: in MathLib 1.0 and later
  245. * CarbonLib: in CarbonLib 1.0 and later
  246. * Mac OS X: in version 10.0 and later
  247. */
  248. EXTERN_API_C( double_t ) atanh(double_t x);
  249. /********************************************************************************
  250. * *
  251. * Exponential functions *
  252. * *
  253. * expm1 expm1(x) = exp(x) - 1. But, for small enough arguments, *
  254. * expm1(x) is expected to be more accurate than exp(x) - 1. *
  255. * frexp Breaks a floating-point number into a normalized fraction *
  256. * and an integral power of 2. It stores the integer in the *
  257. * object pointed by *exponent. *
  258. * ldexp Multiplies a floating-point number by an integer power of 2. *
  259. * log1p log1p = log(1 + x). But, for small enough arguments, *
  260. * log1p is expected to be more accurate than log(1 + x). *
  261. * logb Extracts the exponent of its argument, as a signed integral *
  262. * value. A subnormal argument is treated as though it were first *
  263. * normalized. Thus: *
  264. * 1 <= x * 2^(-logb(x)) < 2 *
  265. * modf Returns fractional part of x as function result and returns *
  266. * integral part of x via iptr. Note C9X uses double not double_t. *
  267. * scalb Computes x * 2^n efficently. This is not normally done by *
  268. * computing 2^n explicitly. *
  269. * *
  270. ********************************************************************************/
  271. /*
  272. * exp()
  273. *
  274. * Availability:
  275. * Non-Carbon CFM: in MathLib 1.0 and later
  276. * CarbonLib: in CarbonLib 1.0 and later
  277. * Mac OS X: in version 10.0 and later
  278. */
  279. EXTERN_API_C( double_t ) exp(double_t x);
  280. /*
  281. * expm1()
  282. *
  283. * Availability:
  284. * Non-Carbon CFM: in MathLib 1.0 and later
  285. * CarbonLib: in CarbonLib 1.0 and later
  286. * Mac OS X: in version 10.0 and later
  287. */
  288. EXTERN_API_C( double_t ) expm1(double_t x);
  289. /*
  290. * exp2()
  291. *
  292. * Availability:
  293. * Non-Carbon CFM: in MathLib 1.0 and later
  294. * CarbonLib: in CarbonLib 1.0 and later
  295. * Mac OS X: in version 10.0 and later
  296. */
  297. EXTERN_API_C( double_t ) exp2(double_t x);
  298. /*
  299. * frexp()
  300. *
  301. * Availability:
  302. * Non-Carbon CFM: in MathLib 1.0 and later
  303. * CarbonLib: in CarbonLib 1.0 and later
  304. * Mac OS X: in version 10.0 and later
  305. */
  306. EXTERN_API_C( double_t ) frexp(double_t x, int *exponent);
  307. /*
  308. * ldexp()
  309. *
  310. * Availability:
  311. * Non-Carbon CFM: in MathLib 1.0 and later
  312. * CarbonLib: in CarbonLib 1.0 and later
  313. * Mac OS X: in version 10.0 and later
  314. */
  315. EXTERN_API_C( double_t ) ldexp(double_t x, int n);
  316. /*
  317. * log()
  318. *
  319. * Availability:
  320. * Non-Carbon CFM: in MathLib 1.0 and later
  321. * CarbonLib: in CarbonLib 1.0 and later
  322. * Mac OS X: in version 10.0 and later
  323. */
  324. EXTERN_API_C( double_t ) log(double_t x);
  325. /*
  326. * log2()
  327. *
  328. * Availability:
  329. * Non-Carbon CFM: in MathLib 1.0 and later
  330. * CarbonLib: in CarbonLib 1.0 and later
  331. * Mac OS X: in version 10.0 and later
  332. */
  333. EXTERN_API_C( double_t ) log2(double_t x);
  334. /*
  335. * log1p()
  336. *
  337. * Availability:
  338. * Non-Carbon CFM: in MathLib 1.0 and later
  339. * CarbonLib: in CarbonLib 1.0 and later
  340. * Mac OS X: in version 10.0 and later
  341. */
  342. EXTERN_API_C( double_t ) log1p(double_t x);
  343. /*
  344. * log10()
  345. *
  346. * Availability:
  347. * Non-Carbon CFM: in MathLib 1.0 and later
  348. * CarbonLib: in CarbonLib 1.0 and later
  349. * Mac OS X: in version 10.0 and later
  350. */
  351. EXTERN_API_C( double_t ) log10(double_t x);
  352. /*
  353. * logb()
  354. *
  355. * Availability:
  356. * Non-Carbon CFM: in MathLib 1.0 and later
  357. * CarbonLib: in CarbonLib 1.0 and later
  358. * Mac OS X: in version 10.0 and later
  359. */
  360. EXTERN_API_C( double_t ) logb(double_t x);
  361. #if !TYPE_LONGDOUBLE_IS_DOUBLE
  362. /*
  363. * modfl()
  364. *
  365. * Availability:
  366. * Non-Carbon CFM: in MathLib 1.0 and later
  367. * CarbonLib: in CarbonLib 1.0 and later
  368. * Mac OS X: not available
  369. */
  370. EXTERN_API_C( long double ) modfl(long double x, long double *iptrl);
  371. #endif /* !TYPE_LONGDOUBLE_IS_DOUBLE */
  372. /*
  373. * modf()
  374. *
  375. * Availability:
  376. * Non-Carbon CFM: in MathLib 1.0 and later
  377. * CarbonLib: in CarbonLib 1.0 and later
  378. * Mac OS X: in version 10.0 and later
  379. */
  380. EXTERN_API_C( double_t ) modf(double_t x, double_t *iptr);
  381. /*
  382. * modff()
  383. *
  384. * Availability:
  385. * Non-Carbon CFM: in MathLib 1.0 and later
  386. * CarbonLib: in CarbonLib 1.0 and later
  387. * Mac OS X: in version 10.0 and later
  388. */
  389. EXTERN_API_C( float ) modff(float x, float *iptrf);
  390. /*
  391. Note: For compatiblity scalb(x,n) has n of type
  392. int on Mac OS X
  393. long on Mac OS
  394. */
  395. typedef long _scalb_n_type;
  396. /*
  397. * scalb()
  398. *
  399. * Availability:
  400. * Non-Carbon CFM: in MathLib 1.0 and later
  401. * CarbonLib: in CarbonLib 1.0 and later
  402. * Mac OS X: in version 10.0 and later
  403. */
  404. EXTERN_API_C( double_t ) scalb(double_t x, _scalb_n_type n);
  405. /********************************************************************************
  406. * *
  407. * Power and absolute value functions *
  408. * *
  409. * hypot Computes the square root of the sum of the squares of its *
  410. * arguments, without undue overflow or underflow. *
  411. * pow Returns x raised to the power of y. Result is more accurate *
  412. * than using exp(log(x)*y). *
  413. * *
  414. ********************************************************************************/
  415. /*
  416. * fabs()
  417. *
  418. * Availability:
  419. * Non-Carbon CFM: in MathLib 1.0 and later
  420. * CarbonLib: in CarbonLib 1.0 and later
  421. * Mac OS X: in version 10.0 and later
  422. */
  423. EXTERN_API_C( double_t ) fabs(double_t x);
  424. /*
  425. * hypot()
  426. *
  427. * Availability:
  428. * Non-Carbon CFM: in MathLib 1.0 and later
  429. * CarbonLib: in CarbonLib 1.0 and later
  430. * Mac OS X: in version 10.0 and later
  431. */
  432. EXTERN_API_C( double_t ) hypot(double_t x, double_t y);
  433. /*
  434. * pow()
  435. *
  436. * Availability:
  437. * Non-Carbon CFM: in MathLib 2.0 and later
  438. * CarbonLib: in CarbonLib 1.0 and later
  439. * Mac OS X: in version 10.0 and later
  440. */
  441. EXTERN_API_C( double_t ) pow(double_t x, double_t y);
  442. /*
  443. * sqrt()
  444. *
  445. * Availability:
  446. * Non-Carbon CFM: in MathLib 1.0 and later
  447. * CarbonLib: in CarbonLib 1.0 and later
  448. * Mac OS X: in version 10.0 and later
  449. */
  450. EXTERN_API_C( double_t ) sqrt(double_t x);
  451. /********************************************************************************
  452. * *
  453. * Gamma and Error functions *
  454. * *
  455. * erf The error function. *
  456. * erfc Complementary error function. *
  457. * gamma The gamma function. *
  458. * lgamma Computes the base-e logarithm of the absolute value of *
  459. * gamma of its argument x, for x > 0. *
  460. * *
  461. ********************************************************************************/
  462. /*
  463. * erf()
  464. *
  465. * Availability:
  466. * Non-Carbon CFM: in MathLib 1.0 and later
  467. * CarbonLib: in CarbonLib 1.0 and later
  468. * Mac OS X: in version 10.0 and later
  469. */
  470. EXTERN_API_C( double_t ) erf(double_t x);
  471. /*
  472. * erfc()
  473. *
  474. * Availability:
  475. * Non-Carbon CFM: in MathLib 1.0 and later
  476. * CarbonLib: in CarbonLib 1.0 and later
  477. * Mac OS X: in version 10.0 and later
  478. */
  479. EXTERN_API_C( double_t ) erfc(double_t x);
  480. /*
  481. * gamma()
  482. *
  483. * Availability:
  484. * Non-Carbon CFM: in MathLib 1.0 and later
  485. * CarbonLib: in CarbonLib 1.0 and later
  486. * Mac OS X: in version 10.0 and later
  487. */
  488. EXTERN_API_C( double_t ) gamma(double_t x);
  489. /*
  490. * lgamma()
  491. *
  492. * Availability:
  493. * Non-Carbon CFM: in MathLib 1.0 and later
  494. * CarbonLib: in CarbonLib 1.0 and later
  495. * Mac OS X: in version 10.0 and later
  496. */
  497. EXTERN_API_C( double_t ) lgamma(double_t x);
  498. /********************************************************************************
  499. * *
  500. * Nearest integer functions *
  501. * *
  502. * rint Rounds its argument to an integral value in floating point *
  503. * format, honoring the current rounding direction. *
  504. * *
  505. * nearbyint Differs from rint only in that it does not raise the inexact *
  506. * exception. It is the nearbyint function recommended by the *
  507. * IEEE floating-point standard 854. *
  508. * *
  509. * rinttol Rounds its argument to the nearest long int using the current *
  510. * rounding direction. NOTE: if the rounded value is outside *
  511. * the range of long int, then the result is undefined. *
  512. * *
  513. * round Rounds the argument to the nearest integral value in floating *
  514. * point format similar to the Fortran "anint" function. That is: *
  515. * add half to the magnitude and chop. *
  516. * *
  517. * roundtol Similar to the Fortran function nint or to the Pascal round. *
  518. * NOTE: if the rounded value is outside the range of long int, *
  519. * then the result is undefined. *
  520. * *
  521. * trunc Computes the integral value, in floating format, nearest to *
  522. * but no larger in magnitude than its argument. NOTE: on 68K *
  523. * compilers when using -elems881, trunc must return an int *
  524. * *
  525. ********************************************************************************/
  526. /*
  527. * ceil()
  528. *
  529. * Availability:
  530. * Non-Carbon CFM: in MathLib 1.0 and later
  531. * CarbonLib: in CarbonLib 1.0 and later
  532. * Mac OS X: in version 10.0 and later
  533. */
  534. EXTERN_API_C( double_t ) ceil(double_t x);
  535. /*
  536. * floor()
  537. *
  538. * Availability:
  539. * Non-Carbon CFM: in MathLib 1.0 and later
  540. * CarbonLib: in CarbonLib 1.0 and later
  541. * Mac OS X: in version 10.0 and later
  542. */
  543. EXTERN_API_C( double_t ) floor(double_t x);
  544. /*
  545. * rint()
  546. *
  547. * Availability:
  548. * Non-Carbon CFM: in MathLib 1.0 and later
  549. * CarbonLib: in CarbonLib 1.0 and later
  550. * Mac OS X: in version 10.0 and later
  551. */
  552. EXTERN_API_C( double_t ) rint(double_t x);
  553. /*
  554. * nearbyint()
  555. *
  556. * Availability:
  557. * Non-Carbon CFM: in MathLib 1.0 and later
  558. * CarbonLib: in CarbonLib 1.0 and later
  559. * Mac OS X: in version 10.0 and later
  560. */
  561. EXTERN_API_C( double_t ) nearbyint(double_t x);
  562. /*
  563. * rinttol()
  564. *
  565. * Availability:
  566. * Non-Carbon CFM: in MathLib 1.0 and later
  567. * CarbonLib: in CarbonLib 1.0 and later
  568. * Mac OS X: in version 10.0 and later
  569. */
  570. EXTERN_API_C( long ) rinttol(double_t x);
  571. /*
  572. * round()
  573. *
  574. * Availability:
  575. * Non-Carbon CFM: in MathLib 1.0 and later
  576. * CarbonLib: in CarbonLib 1.0 and later
  577. * Mac OS X: in version 10.0 and later
  578. */
  579. EXTERN_API_C( double_t ) round(double_t x);
  580. /*
  581. * roundtol()
  582. *
  583. * Availability:
  584. * Non-Carbon CFM: in MathLib 1.0 and later
  585. * CarbonLib: in CarbonLib 1.0 and later
  586. * Mac OS X: in version 10.0 and later
  587. */
  588. EXTERN_API_C( long ) roundtol(double_t round);
  589. /*
  590. Note: For compatiblity trunc(x) has a return type of
  591. int for classic 68K with FPU enabled
  592. double_t everywhere else
  593. */
  594. #if TARGET_RT_MAC_68881
  595. typedef int _trunc_return_type;
  596. #else
  597. typedef double_t _trunc_return_type;
  598. #endif /* TARGET_RT_MAC_68881 */
  599. /*
  600. * trunc()
  601. *
  602. * Availability:
  603. * Non-Carbon CFM: in MathLib 1.0 and later
  604. * CarbonLib: in CarbonLib 1.0 and later
  605. * Mac OS X: in version 10.0 and later
  606. */
  607. EXTERN_API_C( _trunc_return_type ) trunc(double_t x);
  608. /********************************************************************************
  609. * *
  610. * Remainder functions *
  611. * *
  612. * remainder IEEE 754 floating point standard for remainder. *
  613. * remquo SANE remainder. It stores into 'quotient' the 7 low-order *
  614. * bits of the integer quotient x/y, such that: *
  615. * -127 <= quotient <= 127. *
  616. * *
  617. ********************************************************************************/
  618. /*
  619. * fmod()
  620. *
  621. * Availability:
  622. * Non-Carbon CFM: in MathLib 1.0 and later
  623. * CarbonLib: in CarbonLib 1.0 and later
  624. * Mac OS X: in version 10.0 and later
  625. */
  626. EXTERN_API_C( double_t ) fmod(double_t x, double_t y);
  627. /*
  628. * remainder()
  629. *
  630. * Availability:
  631. * Non-Carbon CFM: in MathLib 1.0 and later
  632. * CarbonLib: in CarbonLib 1.0 and later
  633. * Mac OS X: in version 10.0 and later
  634. */
  635. EXTERN_API_C( double_t ) remainder(double_t x, double_t y);
  636. /*
  637. * remquo()
  638. *
  639. * Availability:
  640. * Non-Carbon CFM: in MathLib 1.0 and later
  641. * CarbonLib: in CarbonLib 1.0 and later
  642. * Mac OS X: in version 10.0 and later
  643. */
  644. EXTERN_API_C( double_t ) remquo(double_t x, double_t y, int *quo);
  645. /********************************************************************************
  646. * *
  647. * Auxiliary functions *
  648. * *
  649. * copysign Produces a value with the magnitude of its first argument *
  650. * and sign of its second argument. NOTE: the order of the *
  651. * arguments matches the recommendation of the IEEE 754 *
  652. * floating point standard, which is opposite from the SANE *
  653. * copysign function. *
  654. * *
  655. * nan The call 'nan("n-char-sequence")' returns a quiet NaN *
  656. * with content indicated through tagp in the selected *
  657. * data type format. *
  658. * *
  659. * nextafter Computes the next representable value after 'x' in the *
  660. * direction of 'y'. if x == y, then y is returned. *
  661. * *
  662. ********************************************************************************/
  663. /*
  664. * copysign()
  665. *
  666. * Availability:
  667. * Non-Carbon CFM: in MathLib 1.0 and later
  668. * CarbonLib: in CarbonLib 1.0 and later
  669. * Mac OS X: in version 10.0 and later
  670. */
  671. EXTERN_API_C( double_t ) copysign(double_t x, double_t y);
  672. /*
  673. * nan()
  674. *
  675. * Availability:
  676. * Non-Carbon CFM: in MathLib 1.0 and later
  677. * CarbonLib: in CarbonLib 1.0 and later
  678. * Mac OS X: in version 10.0 and later
  679. */
  680. EXTERN_API_C( double ) nan(const char * tagp);
  681. /*
  682. * nanf()
  683. *
  684. * Availability:
  685. * Non-Carbon CFM: in MathLib 1.0 and later
  686. * CarbonLib: in CarbonLib 1.0 and later
  687. * Mac OS X: in version 10.0 and later
  688. */
  689. EXTERN_API_C( float ) nanf(const char * tagp);
  690. /*
  691. * nanl()
  692. *
  693. * Availability:
  694. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  695. * CarbonLib: in CarbonLib 1.0 and later
  696. * Mac OS X: not available
  697. */
  698. EXTERN_API_C( long double ) nanl(const char * tagp);
  699. #if TYPE_LONGDOUBLE_IS_DOUBLE
  700. #ifdef __cplusplus
  701. inline DEFINE_API_C(long double ) nanl(const char *tagp) { return (long double) nan(tagp); }
  702. #else
  703. #define nanl(tagp) ((long double) nan(tagp))
  704. #endif
  705. #endif
  706. /*
  707. * nextafterd()
  708. *
  709. * Availability:
  710. * Non-Carbon CFM: in MathLib 1.0 and later
  711. * CarbonLib: in CarbonLib 1.0 and later
  712. * Mac OS X: in version 10.0 and later
  713. */
  714. EXTERN_API_C( double ) nextafterd(double x, double y);
  715. /*
  716. * nextafterf()
  717. *
  718. * Availability:
  719. * Non-Carbon CFM: in MathLib 1.0 and later
  720. * CarbonLib: in CarbonLib 1.0 and later
  721. * Mac OS X: in version 10.0 and later
  722. */
  723. EXTERN_API_C( float ) nextafterf(float x, float y);
  724. /*
  725. * nextafterl()
  726. *
  727. * Availability:
  728. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  729. * CarbonLib: in CarbonLib 1.0 and later
  730. * Mac OS X: not available
  731. */
  732. EXTERN_API_C( long double ) nextafterl(long double x, long double y);
  733. #if TYPE_LONGDOUBLE_IS_DOUBLE
  734. #ifdef __cplusplus
  735. inline DEFINE_API_C(long double ) nextafterl(long double x, long double y) { return (long double) nextafterd((double)(x),(double)(y)); }
  736. #else
  737. #define nextafterl(x, y) ((long double) nextafterd((double)(x),(double)(y)))
  738. #endif
  739. #endif
  740. /*
  741. * __fpclassifyd()
  742. *
  743. * Availability:
  744. * Non-Carbon CFM: in MathLib 1.0 and later
  745. * CarbonLib: in CarbonLib 1.0 and later
  746. * Mac OS X: in version 10.0 and later
  747. */
  748. EXTERN_API_C( long ) __fpclassifyd(double x);
  749. /*
  750. * __fpclassifyf()
  751. *
  752. * Availability:
  753. * Non-Carbon CFM: in MathLib 1.0 and later
  754. * CarbonLib: in CarbonLib 1.0 and later
  755. * Mac OS X: in version 10.0 and later
  756. */
  757. EXTERN_API_C( long ) __fpclassifyf(float x);
  758. /*
  759. * __fpclassify()
  760. *
  761. * Availability:
  762. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  763. * CarbonLib: in CarbonLib 1.0 and later
  764. * Mac OS X: not available
  765. */
  766. EXTERN_API_C( long ) __fpclassify(long double x);
  767. #if TYPE_LONGDOUBLE_IS_DOUBLE
  768. #ifdef __cplusplus
  769. inline DEFINE_API_C(long ) __fpclassify(long double x) { return __fpclassifyd((double)(x)); }
  770. #else
  771. #define __fpclassify(x) (__fpclassifyd((double)(x)))
  772. #endif
  773. #endif
  774. /*
  775. * __isnormald()
  776. *
  777. * Availability:
  778. * Non-Carbon CFM: in MathLib 1.0 and later
  779. * CarbonLib: in CarbonLib 1.0 and later
  780. * Mac OS X: in version 10.0 and later
  781. */
  782. EXTERN_API_C( long ) __isnormald(double x);
  783. /*
  784. * __isnormalf()
  785. *
  786. * Availability:
  787. * Non-Carbon CFM: in MathLib 1.0 and later
  788. * CarbonLib: in CarbonLib 1.0 and later
  789. * Mac OS X: in version 10.0 and later
  790. */
  791. EXTERN_API_C( long ) __isnormalf(float x);
  792. /*
  793. * __isnormal()
  794. *
  795. * Availability:
  796. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  797. * CarbonLib: in CarbonLib 1.0 and later
  798. * Mac OS X: not available
  799. */
  800. EXTERN_API_C( long ) __isnormal(long double x);
  801. #if TYPE_LONGDOUBLE_IS_DOUBLE
  802. #ifdef __cplusplus
  803. inline DEFINE_API_C(long ) __isnormal(long double x) { return __isnormald((double)(x)); }
  804. #else
  805. #define __isnormal(x) (__isnormald((double)(x)))
  806. #endif
  807. #endif
  808. /*
  809. * __isfinited()
  810. *
  811. * Availability:
  812. * Non-Carbon CFM: in MathLib 1.0 and later
  813. * CarbonLib: in CarbonLib 1.0 and later
  814. * Mac OS X: in version 10.0 and later
  815. */
  816. EXTERN_API_C( long ) __isfinited(double x);
  817. /*
  818. * __isfinitef()
  819. *
  820. * Availability:
  821. * Non-Carbon CFM: in MathLib 1.0 and later
  822. * CarbonLib: in CarbonLib 1.0 and later
  823. * Mac OS X: in version 10.0 and later
  824. */
  825. EXTERN_API_C( long ) __isfinitef(float x);
  826. /*
  827. * __isfinite()
  828. *
  829. * Availability:
  830. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  831. * CarbonLib: in CarbonLib 1.0 and later
  832. * Mac OS X: not available
  833. */
  834. EXTERN_API_C( long ) __isfinite(long double x);
  835. #if TYPE_LONGDOUBLE_IS_DOUBLE
  836. #ifdef __cplusplus
  837. inline DEFINE_API_C(long ) __isfinite(long double x) { return __isfinited((double)(x)); }
  838. #else
  839. #define __isfinite(x) (__isfinited((double)(x)))
  840. #endif
  841. #endif
  842. /*
  843. * __isnand()
  844. *
  845. * Availability:
  846. * Non-Carbon CFM: in MathLib 1.0 and later
  847. * CarbonLib: in CarbonLib 1.0 and later
  848. * Mac OS X: in version 10.0 and later
  849. */
  850. EXTERN_API_C( long ) __isnand(double x);
  851. /*
  852. * __isnanf()
  853. *
  854. * Availability:
  855. * Non-Carbon CFM: in MathLib 1.0 and later
  856. * CarbonLib: in CarbonLib 1.0 and later
  857. * Mac OS X: in version 10.0 and later
  858. */
  859. EXTERN_API_C( long ) __isnanf(float x);
  860. /*
  861. * __isnan()
  862. *
  863. * Availability:
  864. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  865. * CarbonLib: in CarbonLib 1.0 and later
  866. * Mac OS X: not available
  867. */
  868. EXTERN_API_C( long ) __isnan(long double x);
  869. #if TYPE_LONGDOUBLE_IS_DOUBLE
  870. #ifdef __cplusplus
  871. inline DEFINE_API_C(long ) __isnan(long double x) { return __isnand((double)(x)); }
  872. #else
  873. #define __isnan(x) (__isnand((double)(x)))
  874. #endif
  875. #endif
  876. /*
  877. * __signbitd()
  878. *
  879. * Availability:
  880. * Non-Carbon CFM: in MathLib 1.0 and later
  881. * CarbonLib: in CarbonLib 1.0 and later
  882. * Mac OS X: in version 10.0 and later
  883. */
  884. EXTERN_API_C( long ) __signbitd(double x);
  885. /*
  886. * __signbitf()
  887. *
  888. * Availability:
  889. * Non-Carbon CFM: in MathLib 1.0 and later
  890. * CarbonLib: in CarbonLib 1.0 and later
  891. * Mac OS X: in version 10.0 and later
  892. */
  893. EXTERN_API_C( long ) __signbitf(float x);
  894. /*
  895. * __signbit()
  896. *
  897. * Availability:
  898. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  899. * CarbonLib: in CarbonLib 1.0 and later
  900. * Mac OS X: not available
  901. */
  902. EXTERN_API_C( long ) __signbit(long double x);
  903. #if TYPE_LONGDOUBLE_IS_DOUBLE
  904. #ifdef __cplusplus
  905. inline DEFINE_API_C(long ) __signbit(long double x) { return __signbitd((double)(x)); }
  906. #else
  907. #define __signbit(x) (__signbitd((double)(x)))
  908. #endif
  909. #endif
  910. /*
  911. * __inf()
  912. *
  913. * Availability:
  914. * Non-Carbon CFM: in MathLib 1.0 and later
  915. * CarbonLib: in CarbonLib 1.0 and later
  916. * Mac OS X: in version 10.0 and later
  917. */
  918. EXTERN_API_C( double_t ) __inf(void);
  919. /********************************************************************************
  920. * *
  921. * Inquiry macros *
  922. * *
  923. * fpclassify Returns one of the FP_* values. *
  924. * isnormal Non-zero if and only if the argument x is normalized. *
  925. * isfinite Non-zero if and only if the argument x is finite. *
  926. * isnan Non-zero if and only if the argument x is a NaN. *
  927. * signbit Non-zero if and only if the sign of the argument x is *
  928. * negative. This includes, NaNs, infinities and zeros. *
  929. * *
  930. ********************************************************************************/
  931. enum {
  932. FP_SNAN = 0, /* signaling NaN */
  933. FP_QNAN = 1, /* quiet NaN */
  934. FP_INFINITE = 2, /* + or - infinity */
  935. FP_ZERO = 3, /* + or - zero */
  936. FP_NORMAL = 4, /* all normal numbers */
  937. FP_SUBNORMAL = 5 /* denormal numbers */
  938. };
  939. #define fpclassify(x) ( ( sizeof ( x ) == sizeof(double) ) ? \
  940. __fpclassifyd ( x ) : \
  941. ( sizeof ( x ) == sizeof(float) ) ? \
  942. __fpclassifyf ( x ) : \
  943. __fpclassify ( x ) )
  944. #define isnormal(x) ( ( sizeof ( x ) == sizeof(double) ) ? \
  945. __isnormald ( x ) : \
  946. ( sizeof ( x ) == sizeof(float) ) ? \
  947. __isnormalf ( x ) : \
  948. __isnormal ( x ) )
  949. #define isfinite(x) ( ( sizeof ( x ) == sizeof(double) ) ? \
  950. __isfinited ( x ) : \
  951. ( sizeof ( x ) == sizeof(float) ) ? \
  952. __isfinitef ( x ) : \
  953. __isfinite ( x ) )
  954. #define isnan(x) ( ( sizeof ( x ) == sizeof(double) ) ? \
  955. __isnand ( x ) : \
  956. ( sizeof ( x ) == sizeof(float) ) ? \
  957. __isnanf ( x ) : \
  958. __isnan ( x ) )
  959. #define signbit(x) ( ( sizeof ( x ) == sizeof(double) ) ? \
  960. __signbitd ( x ) : \
  961. ( sizeof ( x ) == sizeof(float) ) ? \
  962. __signbitf ( x ) : \
  963. __signbit ( x ) )
  964. /********************************************************************************
  965. * *
  966. * Max, Min and Positive Difference *
  967. * *
  968. * fdim Determines the 'positive difference' between its arguments: *
  969. * { x - y, if x > y }, { +0, if x <= y }. If one argument is *
  970. * NaN, then fdim returns that NaN. if both arguments are NaNs, *
  971. * then fdim returns the first argument. *
  972. * *
  973. * fmax Returns the maximum of the two arguments. Corresponds to the *
  974. * max function in FORTRAN. NaN arguments are treated as missing *
  975. * data. If one argument is NaN and the other is a number, then *
  976. * the number is returned. If both are NaNs then the first *
  977. * argument is returned. *
  978. * *
  979. * fmin Returns the minimum of the two arguments. Corresponds to the *
  980. * min function in FORTRAN. NaN arguments are treated as missing *
  981. * data. If one argument is NaN and the other is a number, then *
  982. * the number is returned. If both are NaNs then the first *
  983. * argument is returned. *
  984. * *
  985. ********************************************************************************/
  986. /*
  987. * fdim()
  988. *
  989. * Availability:
  990. * Non-Carbon CFM: in MathLib 1.0 and later
  991. * CarbonLib: in CarbonLib 1.0 and later
  992. * Mac OS X: in version 10.0 and later
  993. */
  994. EXTERN_API_C( double_t ) fdim(double_t x, double_t y);
  995. /*
  996. * fmax()
  997. *
  998. * Availability:
  999. * Non-Carbon CFM: in MathLib 1.0 and later
  1000. * CarbonLib: in CarbonLib 1.0 and later
  1001. * Mac OS X: in version 10.0 and later
  1002. */
  1003. EXTERN_API_C( double_t ) fmax(double_t x, double_t y);
  1004. /*
  1005. * fmin()
  1006. *
  1007. * Availability:
  1008. * Non-Carbon CFM: in MathLib 1.0 and later
  1009. * CarbonLib: in CarbonLib 1.0 and later
  1010. * Mac OS X: in version 10.0 and later
  1011. */
  1012. EXTERN_API_C( double_t ) fmin(double_t x, double_t y);
  1013. #endif /* (defined(__MWERKS__) && defined(__cmath__)) || (TARGET_RT_MAC_MACHO && defined(__MATH__)) */
  1014. /*******************************************************************************
  1015. * Constants *
  1016. *******************************************************************************/
  1017. /*
  1018. * pi
  1019. *
  1020. * Availability:
  1021. * Non-Carbon CFM: in MathLib 1.0 and later
  1022. * CarbonLib: in CarbonLib 1.0 and later
  1023. * Mac OS X: in version 10.0 and later
  1024. */
  1025. extern const double_t pi;
  1026. /********************************************************************************
  1027. * *
  1028. * Non NCEG extensions *
  1029. * *
  1030. ********************************************************************************/
  1031. #ifndef __NOEXTENSIONS__
  1032. /********************************************************************************
  1033. * *
  1034. * Financial functions *
  1035. * *
  1036. * compound Computes the compound interest factor "(1 + rate)^periods" *
  1037. * more accurately than the straightforward computation with *
  1038. * the Power function. This is SANE's compound function. *
  1039. * *
  1040. * annuity Computes the present value factor for an annuity *
  1041. * "(1 - (1 + rate)^(-periods)) /rate" more accurately than *
  1042. * the straightforward computation with the Power function. *
  1043. * This is SANE's annuity function. *
  1044. * *
  1045. ********************************************************************************/
  1046. /*
  1047. * compound()
  1048. *
  1049. * Availability:
  1050. * Non-Carbon CFM: in MathLib 1.0 and later
  1051. * CarbonLib: in CarbonLib 1.0 and later
  1052. * Mac OS X: in version 10.0 and later
  1053. */
  1054. EXTERN_API_C( double_t ) compound(double_t rate, double_t periods);
  1055. /*
  1056. * annuity()
  1057. *
  1058. * Availability:
  1059. * Non-Carbon CFM: in MathLib 1.0 and later
  1060. * CarbonLib: in CarbonLib 1.0 and later
  1061. * Mac OS X: in version 10.0 and later
  1062. */
  1063. EXTERN_API_C( double_t ) annuity(double_t rate, double_t periods);
  1064. /********************************************************************************
  1065. * *
  1066. * Random function *
  1067. * *
  1068. * randomx A pseudorandom number generator. It uses the iteration: *
  1069. * (7^5*x)mod(2^31-1) *
  1070. * *
  1071. ********************************************************************************/
  1072. /*
  1073. * randomx()
  1074. *
  1075. * Availability:
  1076. * Non-Carbon CFM: in MathLib 1.0 and later
  1077. * CarbonLib: in CarbonLib 1.0 and later
  1078. * Mac OS X: in version 10.0 and later
  1079. */
  1080. EXTERN_API_C( double_t ) randomx(double_t * x);
  1081. /*******************************************************************************
  1082. * Relational operator *
  1083. *******************************************************************************/
  1084. /* relational operator */
  1085. typedef short relop;
  1086. enum {
  1087. GREATERTHAN = 0,
  1088. LESSTHAN = 1,
  1089. EQUALTO = 2,
  1090. UNORDERED = 3
  1091. };
  1092. #if !defined(__MWERKS__) || !defined(__cmath__)
  1093. /*
  1094. * relation()
  1095. *
  1096. * Availability:
  1097. * Non-Carbon CFM: in MathLib 1.0 and later
  1098. * CarbonLib: in CarbonLib 1.0 and later
  1099. * Mac OS X: in version 10.0 and later
  1100. */
  1101. EXTERN_API_C( relop ) relation(double_t x, double_t y);
  1102. #endif /* !defined(__MWERKS__) || !defined(__cmath__) */
  1103. /********************************************************************************
  1104. * *
  1105. * Binary to decimal conversions *
  1106. * *
  1107. * SIGDIGLEN Significant decimal digits. *
  1108. * *
  1109. * decimal A record which provides an intermediate unpacked form for *
  1110. * programmers who wish to do their own parsing of numeric input *
  1111. * or formatting of numeric output. *
  1112. * *
  1113. * decform Controls each conversion to a decimal string. The style field *
  1114. * is either FLOATDECIMAL or FIXEDDECIMAL. If FLOATDECIMAL, the *
  1115. * value of the field digits is the number of significant digits. *
  1116. * If FIXEDDECIMAL value of the field digits is the number of *
  1117. * digits to the right of the decimal point. *
  1118. * *
  1119. * num2dec Converts a double_t to a decimal record using a decform. *
  1120. * dec2num Converts a decimal record d to a double_t value. *
  1121. * dec2str Converts a decform and decimal to a string using a decform. *
  1122. * str2dec Converts a string to a decimal struct. *
  1123. * dec2d Similar to dec2num except a double is returned (68k only). *
  1124. * dec2f Similar to dec2num except a float is returned. *
  1125. * dec2s Similar to dec2num except a short is returned. *
  1126. * dec2l Similar to dec2num except a long is returned. *
  1127. * *
  1128. ********************************************************************************/
  1129. #if TARGET_CPU_PPC
  1130. #define SIGDIGLEN 36
  1131. #elif TARGET_CPU_68K
  1132. #define SIGDIGLEN 20
  1133. #elif TARGET_CPU_X86
  1134. #define SIGDIGLEN 20
  1135. #endif
  1136. #define DECSTROUTLEN 80 /* max length for dec2str output */
  1137. #define FLOATDECIMAL ((char)(0))
  1138. #define FIXEDDECIMAL ((char)(1))
  1139. struct decimal {
  1140. char sgn; /* sign 0 for +, 1 for - */
  1141. char unused;
  1142. short exp; /* decimal exponent */
  1143. struct {
  1144. unsigned char length;
  1145. unsigned char text[SIGDIGLEN]; /* significant digits */
  1146. unsigned char unused;
  1147. } sig;
  1148. };
  1149. typedef struct decimal decimal;
  1150. struct decform {
  1151. char style; /* FLOATDECIMAL or FIXEDDECIMAL */
  1152. char unused;
  1153. short digits;
  1154. };
  1155. typedef struct decform decform;
  1156. /*
  1157. * num2dec()
  1158. *
  1159. * Availability:
  1160. * Non-Carbon CFM: in MathLib 1.0 and later
  1161. * CarbonLib: in CarbonLib 1.0 and later
  1162. * Mac OS X: in version 10.0 and later
  1163. */
  1164. EXTERN_API_C( void ) num2dec(const decform *f, double_t x, decimal *d);
  1165. /*
  1166. * dec2num()
  1167. *
  1168. * Availability:
  1169. * Non-Carbon CFM: in MathLib 1.0 and later
  1170. * CarbonLib: in CarbonLib 1.0 and later
  1171. * Mac OS X: in version 10.0 and later
  1172. */
  1173. EXTERN_API_C( double_t ) dec2num(const decimal * d);
  1174. /*
  1175. * dec2str()
  1176. *
  1177. * Availability:
  1178. * Non-Carbon CFM: in MathLib 1.0 and later
  1179. * CarbonLib: in CarbonLib 1.0 and later
  1180. * Mac OS X: in version 10.0 and later
  1181. */
  1182. EXTERN_API_C( void ) dec2str(const decform *f, const decimal *d, char *s);
  1183. /*
  1184. * str2dec()
  1185. *
  1186. * Availability:
  1187. * Non-Carbon CFM: in MathLib 1.0 and later
  1188. * CarbonLib: in CarbonLib 1.0 and later
  1189. * Mac OS X: in version 10.0 and later
  1190. */
  1191. EXTERN_API_C( void ) str2dec(const char *s, short *ix, decimal *d, short *vp);
  1192. #if TARGET_CPU_68K
  1193. #if CALL_NOT_IN_CARBON
  1194. /*
  1195. * dec2d()
  1196. *
  1197. * Availability:
  1198. * Non-Carbon CFM: not available
  1199. * CarbonLib: not available
  1200. * Mac OS X: not available
  1201. */
  1202. EXTERN_API_C( double ) dec2d(const decimal * d);
  1203. #endif /* CALL_NOT_IN_CARBON */
  1204. #endif /* TARGET_CPU_68K */
  1205. /*
  1206. * dec2f()
  1207. *
  1208. * Availability:
  1209. * Non-Carbon CFM: in MathLib 1.0 and later
  1210. * CarbonLib: in CarbonLib 1.0 and later
  1211. * Mac OS X: in version 10.0 and later
  1212. */
  1213. EXTERN_API_C( float ) dec2f(const decimal * d);
  1214. /*
  1215. * dec2s()
  1216. *
  1217. * Availability:
  1218. * Non-Carbon CFM: in MathLib 1.0 and later
  1219. * CarbonLib: in CarbonLib 1.0 and later
  1220. * Mac OS X: in version 10.0 and later
  1221. */
  1222. EXTERN_API_C( short ) dec2s(const decimal * d);
  1223. /*
  1224. * dec2l()
  1225. *
  1226. * Availability:
  1227. * Non-Carbon CFM: in MathLib 1.0 and later
  1228. * CarbonLib: in CarbonLib 1.0 and later
  1229. * Mac OS X: in version 10.0 and later
  1230. */
  1231. EXTERN_API_C( long ) dec2l(const decimal * d);
  1232. /********************************************************************************
  1233. * *
  1234. * 68k-only Transfer Function Prototypes *
  1235. * *
  1236. ********************************************************************************/
  1237. #if TARGET_CPU_68K
  1238. #if CALL_NOT_IN_CARBON
  1239. /*
  1240. * x96tox80()
  1241. *
  1242. * Availability:
  1243. * Non-Carbon CFM: not available
  1244. * CarbonLib: not available
  1245. * Mac OS X: not available
  1246. */
  1247. EXTERN_API_C( void ) x96tox80(const extended96 *x, extended80 *x80);
  1248. /*
  1249. * x80tox96()
  1250. *
  1251. * Availability:
  1252. * Non-Carbon CFM: not available
  1253. * CarbonLib: not available
  1254. * Mac OS X: not available
  1255. */
  1256. EXTERN_API_C( void ) x80tox96(const extended80 *x80, extended96 *x);
  1257. #endif /* CALL_NOT_IN_CARBON */
  1258. #endif /* TARGET_CPU_68K */
  1259. #endif /* !defined(__NOEXTENSIONS__) */
  1260. /********************************************************************************
  1261. * *
  1262. * PowerPC-only Function Prototypes *
  1263. * *
  1264. ********************************************************************************/
  1265. #if TARGET_CPU_PPC
  1266. #ifndef __MWERKS__ /* Metrowerks does not support double double */
  1267. /*
  1268. * cosl()
  1269. *
  1270. * Availability:
  1271. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1272. * CarbonLib: in CarbonLib 1.0 and later
  1273. * Mac OS X: not available
  1274. */
  1275. EXTERN_API_C( long double ) cosl(long double x);
  1276. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1277. #ifdef __cplusplus
  1278. inline DEFINE_API_C(long double ) cosl(long double x) { return (long double) cos((double)(x)); }
  1279. #else
  1280. #define cosl(x) ((long double) cos((double)(x)))
  1281. #endif
  1282. #endif
  1283. /*
  1284. * sinl()
  1285. *
  1286. * Availability:
  1287. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1288. * CarbonLib: in CarbonLib 1.0 and later
  1289. * Mac OS X: not available
  1290. */
  1291. EXTERN_API_C( long double ) sinl(long double x);
  1292. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1293. #ifdef __cplusplus
  1294. inline DEFINE_API_C(long double ) sinl(long double x) { return (long double) sin((double)(x)); }
  1295. #else
  1296. #define sinl(x) ((long double) sin((double)(x)))
  1297. #endif
  1298. #endif
  1299. /*
  1300. * tanl()
  1301. *
  1302. * Availability:
  1303. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1304. * CarbonLib: in CarbonLib 1.0 and later
  1305. * Mac OS X: not available
  1306. */
  1307. EXTERN_API_C( long double ) tanl(long double x);
  1308. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1309. #ifdef __cplusplus
  1310. inline DEFINE_API_C(long double ) tanl(long double x) { return (long double) tan((double)(x)); }
  1311. #else
  1312. #define tanl(x) ((long double) tan((double)(x)))
  1313. #endif
  1314. #endif
  1315. /*
  1316. * acosl()
  1317. *
  1318. * Availability:
  1319. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1320. * CarbonLib: in CarbonLib 1.0 and later
  1321. * Mac OS X: not available
  1322. */
  1323. EXTERN_API_C( long double ) acosl(long double x);
  1324. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1325. #ifdef __cplusplus
  1326. inline DEFINE_API_C(long double ) acosl(long double x) { return (long double) acos((double)(x)); }
  1327. #else
  1328. #define acosl(x) ((long double) acos((double)(x)))
  1329. #endif
  1330. #endif
  1331. /*
  1332. * asinl()
  1333. *
  1334. * Availability:
  1335. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1336. * CarbonLib: in CarbonLib 1.0 and later
  1337. * Mac OS X: not available
  1338. */
  1339. EXTERN_API_C( long double ) asinl(long double x);
  1340. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1341. #ifdef __cplusplus
  1342. inline DEFINE_API_C(long double ) asinl(long double x) { return (long double) asin((double)(x)); }
  1343. #else
  1344. #define asinl(x) ((long double) asin((double)(x)))
  1345. #endif
  1346. #endif
  1347. /*
  1348. * atanl()
  1349. *
  1350. * Availability:
  1351. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1352. * CarbonLib: in CarbonLib 1.0 and later
  1353. * Mac OS X: not available
  1354. */
  1355. EXTERN_API_C( long double ) atanl(long double x);
  1356. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1357. #ifdef __cplusplus
  1358. inline DEFINE_API_C(long double ) atanl(long double x) { return (long double) atan((double)(x)); }
  1359. #else
  1360. #define atanl(x) ((long double) atan((double)(x)))
  1361. #endif
  1362. #endif
  1363. /*
  1364. * atan2l()
  1365. *
  1366. * Availability:
  1367. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1368. * CarbonLib: in CarbonLib 1.0 and later
  1369. * Mac OS X: not available
  1370. */
  1371. EXTERN_API_C( long double ) atan2l(long double y, long double x);
  1372. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1373. #ifdef __cplusplus
  1374. inline DEFINE_API_C(long double ) atan2l(long double y, long double x) { return (long double) atan2((double)(y), (double)(x)); }
  1375. #else
  1376. #define atan2l(y, x) ((long double) atan2((double)(y), (double)(x)))
  1377. #endif
  1378. #endif
  1379. /*
  1380. * coshl()
  1381. *
  1382. * Availability:
  1383. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1384. * CarbonLib: in CarbonLib 1.0 and later
  1385. * Mac OS X: not available
  1386. */
  1387. EXTERN_API_C( long double ) coshl(long double x);
  1388. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1389. #ifdef __cplusplus
  1390. inline DEFINE_API_C(long double ) coshl(long double x) { return (long double) cosh((double)(x)); }
  1391. #else
  1392. #define coshl(x) ((long double) cosh((double)(x)))
  1393. #endif
  1394. #endif
  1395. /*
  1396. * sinhl()
  1397. *
  1398. * Availability:
  1399. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1400. * CarbonLib: in CarbonLib 1.0 and later
  1401. * Mac OS X: not available
  1402. */
  1403. EXTERN_API_C( long double ) sinhl(long double x);
  1404. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1405. #ifdef __cplusplus
  1406. inline DEFINE_API_C(long double ) sinhl(long double x) { return (long double) sinh((double)(x)); }
  1407. #else
  1408. #define sinhl(x) ((long double) sinh((double)(x)))
  1409. #endif
  1410. #endif
  1411. /*
  1412. * tanhl()
  1413. *
  1414. * Availability:
  1415. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1416. * CarbonLib: in CarbonLib 1.0 and later
  1417. * Mac OS X: not available
  1418. */
  1419. EXTERN_API_C( long double ) tanhl(long double x);
  1420. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1421. #ifdef __cplusplus
  1422. inline DEFINE_API_C(long double ) tanhl(long double x) { return (long double) tanh((double)(x)); }
  1423. #else
  1424. #define tanhl(x) ((long double) tanh((double)(x)))
  1425. #endif
  1426. #endif
  1427. /*
  1428. * acoshl()
  1429. *
  1430. * Availability:
  1431. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1432. * CarbonLib: in CarbonLib 1.0 and later
  1433. * Mac OS X: not available
  1434. */
  1435. EXTERN_API_C( long double ) acoshl(long double x);
  1436. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1437. #ifdef __cplusplus
  1438. inline DEFINE_API_C(long double ) acoshl(long double x) { return (long double) acosh((double)(x)); }
  1439. #else
  1440. #define acoshl(x) ((long double) acosh((double)(x)))
  1441. #endif
  1442. #endif
  1443. /*
  1444. * asinhl()
  1445. *
  1446. * Availability:
  1447. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1448. * CarbonLib: in CarbonLib 1.0 and later
  1449. * Mac OS X: not available
  1450. */
  1451. EXTERN_API_C( long double ) asinhl(long double x);
  1452. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1453. #ifdef __cplusplus
  1454. inline DEFINE_API_C(long double ) asinhl(long double x) { return (long double) asinh((double)(x)); }
  1455. #else
  1456. #define asinhl(x) ((long double) asinh((double)(x)))
  1457. #endif
  1458. #endif
  1459. /*
  1460. * atanhl()
  1461. *
  1462. * Availability:
  1463. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1464. * CarbonLib: in CarbonLib 1.0 and later
  1465. * Mac OS X: not available
  1466. */
  1467. EXTERN_API_C( long double ) atanhl(long double x);
  1468. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1469. #ifdef __cplusplus
  1470. inline DEFINE_API_C(long double ) atanhl(long double x) { return (long double) atanh((double)(x)); }
  1471. #else
  1472. #define atanhl(x) ((long double) atanh((double)(x)))
  1473. #endif
  1474. #endif
  1475. /*
  1476. * expl()
  1477. *
  1478. * Availability:
  1479. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1480. * CarbonLib: in CarbonLib 1.0 and later
  1481. * Mac OS X: not available
  1482. */
  1483. EXTERN_API_C( long double ) expl(long double x);
  1484. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1485. #ifdef __cplusplus
  1486. inline DEFINE_API_C(long double ) expl(long double x) { return (long double) exp((double)(x)); }
  1487. #else
  1488. #define expl(x) ((long double) exp((double)(x)))
  1489. #endif
  1490. #endif
  1491. /*
  1492. * expm1l()
  1493. *
  1494. * Availability:
  1495. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1496. * CarbonLib: in CarbonLib 1.0 and later
  1497. * Mac OS X: not available
  1498. */
  1499. EXTERN_API_C( long double ) expm1l(long double x);
  1500. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1501. #ifdef __cplusplus
  1502. inline DEFINE_API_C(long double ) expm1l(long double x) { return (long double) expm1((double)(x)); }
  1503. #else
  1504. #define expm1l(x) ((long double) expm1((double)(x)))
  1505. #endif
  1506. #endif
  1507. /*
  1508. * exp2l()
  1509. *
  1510. * Availability:
  1511. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1512. * CarbonLib: in CarbonLib 1.0 and later
  1513. * Mac OS X: not available
  1514. */
  1515. EXTERN_API_C( long double ) exp2l(long double x);
  1516. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1517. #ifdef __cplusplus
  1518. inline DEFINE_API_C(long double ) exp2l(long double x) { return (long double) exp2((double)(x)); }
  1519. #else
  1520. #define exp2l(x) ((long double) exp2((double)(x)))
  1521. #endif
  1522. #endif
  1523. /*
  1524. * frexpl()
  1525. *
  1526. * Availability:
  1527. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1528. * CarbonLib: in CarbonLib 1.0 and later
  1529. * Mac OS X: not available
  1530. */
  1531. EXTERN_API_C( long double ) frexpl(long double x, int *exponent);
  1532. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1533. #ifdef __cplusplus
  1534. inline DEFINE_API_C(long double ) frexpl(long double x, int *exponent) { return (long double) frexp((double)(x), (exponent)); }
  1535. #else
  1536. #define frexpl(x, exponent) ((long double) frexp((double)(x), (exponent)))
  1537. #endif
  1538. #endif
  1539. /*
  1540. * ldexpl()
  1541. *
  1542. * Availability:
  1543. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1544. * CarbonLib: in CarbonLib 1.0 and later
  1545. * Mac OS X: not available
  1546. */
  1547. EXTERN_API_C( long double ) ldexpl(long double x, int n);
  1548. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1549. #ifdef __cplusplus
  1550. inline DEFINE_API_C(long double ) ldexpl(long double x, int n) { return (long double) ldexp((double)(x), (n)); }
  1551. #else
  1552. #define ldexpl(x, n) ((long double) ldexp((double)(x), (n)))
  1553. #endif
  1554. #endif
  1555. /*
  1556. * logl()
  1557. *
  1558. * Availability:
  1559. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1560. * CarbonLib: in CarbonLib 1.0 and later
  1561. * Mac OS X: not available
  1562. */
  1563. EXTERN_API_C( long double ) logl(long double x);
  1564. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1565. #ifdef __cplusplus
  1566. inline DEFINE_API_C(long double ) logl(long double x) { return (long double) log((double)(x)); }
  1567. #else
  1568. #define logl(x) ((long double) log((double)(x)))
  1569. #endif
  1570. #endif
  1571. /*
  1572. * log1pl()
  1573. *
  1574. * Availability:
  1575. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1576. * CarbonLib: in CarbonLib 1.0 and later
  1577. * Mac OS X: not available
  1578. */
  1579. EXTERN_API_C( long double ) log1pl(long double x);
  1580. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1581. #ifdef __cplusplus
  1582. inline DEFINE_API_C(long double ) log1pl(long double x) { return (long double) log1p((double)(x)); }
  1583. #else
  1584. #define log1pl(x) ((long double) log1p((double)(x)))
  1585. #endif
  1586. #endif
  1587. /*
  1588. * log10l()
  1589. *
  1590. * Availability:
  1591. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1592. * CarbonLib: in CarbonLib 1.0 and later
  1593. * Mac OS X: not available
  1594. */
  1595. EXTERN_API_C( long double ) log10l(long double x);
  1596. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1597. #ifdef __cplusplus
  1598. inline DEFINE_API_C(long double ) log10l(long double x) { return (long double) log10((double)(x)); }
  1599. #else
  1600. #define log10l(x) ((long double) log10((double)(x)))
  1601. #endif
  1602. #endif
  1603. /*
  1604. * log2l()
  1605. *
  1606. * Availability:
  1607. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1608. * CarbonLib: in CarbonLib 1.0 and later
  1609. * Mac OS X: not available
  1610. */
  1611. EXTERN_API_C( long double ) log2l(long double x);
  1612. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1613. #ifdef __cplusplus
  1614. inline DEFINE_API_C(long double ) log2l(long double x) { return (long double) log2((double)(x)); }
  1615. #else
  1616. #define log2l(x) ((long double) log2((double)(x)))
  1617. #endif
  1618. #endif
  1619. /*
  1620. * logbl()
  1621. *
  1622. * Availability:
  1623. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1624. * CarbonLib: in CarbonLib 1.0 and later
  1625. * Mac OS X: not available
  1626. */
  1627. EXTERN_API_C( long double ) logbl(long double x);
  1628. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1629. #ifdef __cplusplus
  1630. inline DEFINE_API_C(long double ) logbl(long double x) { return (long double) logb((double)(x)); }
  1631. #else
  1632. #define logbl(x) ((long double) logb((double)(x)))
  1633. #endif
  1634. #endif
  1635. /*
  1636. * scalbl()
  1637. *
  1638. * Availability:
  1639. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1640. * CarbonLib: in CarbonLib 1.0 and later
  1641. * Mac OS X: not available
  1642. */
  1643. EXTERN_API_C( long double ) scalbl(long double x, long n);
  1644. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1645. #ifdef __cplusplus
  1646. inline DEFINE_API_C(long double ) scalbl(long double x, long n) { return (long double) scalb((double)(x), (n)); }
  1647. #else
  1648. #define scalbl(x, n) ((long double) scalb((double)(x), (n)))
  1649. #endif
  1650. #endif
  1651. /*
  1652. * fabsl()
  1653. *
  1654. * Availability:
  1655. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1656. * CarbonLib: in CarbonLib 1.0 and later
  1657. * Mac OS X: not available
  1658. */
  1659. EXTERN_API_C( long double ) fabsl(long double x);
  1660. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1661. #ifdef __cplusplus
  1662. inline DEFINE_API_C(long double ) fabsl(long double x) { return (long double) fabs((double)(x)); }
  1663. #else
  1664. #define fabsl(x) ((long double) fabs((double)(x)))
  1665. #endif
  1666. #endif
  1667. /*
  1668. * hypotl()
  1669. *
  1670. * Availability:
  1671. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1672. * CarbonLib: in CarbonLib 1.0 and later
  1673. * Mac OS X: not available
  1674. */
  1675. EXTERN_API_C( long double ) hypotl(long double x, long double y);
  1676. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1677. #ifdef __cplusplus
  1678. inline DEFINE_API_C(long double ) hypotl(long double x, long double y) { return (long double) hypot((double)(x), (double)(y)); }
  1679. #else
  1680. #define hypotl(x, y) ((long double) hypot((double)(x), (double)(y)))
  1681. #endif
  1682. #endif
  1683. /*
  1684. * powl()
  1685. *
  1686. * Availability:
  1687. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1688. * CarbonLib: in CarbonLib 1.0 and later
  1689. * Mac OS X: not available
  1690. */
  1691. EXTERN_API_C( long double ) powl(long double x, long double y);
  1692. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1693. #ifdef __cplusplus
  1694. inline DEFINE_API_C(long double ) powl(long double x, long double y) { return (long double) pow((double)(x), (double)(y)); }
  1695. #else
  1696. #define powl(x, y) ((long double) pow((double)(x), (double)(y)))
  1697. #endif
  1698. #endif
  1699. /*
  1700. * sqrtl()
  1701. *
  1702. * Availability:
  1703. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1704. * CarbonLib: in CarbonLib 1.0 and later
  1705. * Mac OS X: not available
  1706. */
  1707. EXTERN_API_C( long double ) sqrtl(long double x);
  1708. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1709. #ifdef __cplusplus
  1710. inline DEFINE_API_C(long double ) sqrtl(long double x) { return (long double) sqrt((double)(x)); }
  1711. #else
  1712. #define sqrtl(x) ((long double) sqrt((double)(x)))
  1713. #endif
  1714. #endif
  1715. /*
  1716. * erfl()
  1717. *
  1718. * Availability:
  1719. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1720. * CarbonLib: in CarbonLib 1.0 and later
  1721. * Mac OS X: not available
  1722. */
  1723. EXTERN_API_C( long double ) erfl(long double x);
  1724. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1725. #ifdef __cplusplus
  1726. inline DEFINE_API_C(long double ) erfl(long double x) { return (long double) erf((double)(x)); }
  1727. #else
  1728. #define erfl(x) ((long double) erf((double)(x)))
  1729. #endif
  1730. #endif
  1731. /*
  1732. * erfcl()
  1733. *
  1734. * Availability:
  1735. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1736. * CarbonLib: in CarbonLib 1.0 and later
  1737. * Mac OS X: not available
  1738. */
  1739. EXTERN_API_C( long double ) erfcl(long double x);
  1740. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1741. #ifdef __cplusplus
  1742. inline DEFINE_API_C(long double ) erfcl(long double x) { return (long double) erfc((double)(x)); }
  1743. #else
  1744. #define erfcl(x) ((long double) erfc((double)(x)))
  1745. #endif
  1746. #endif
  1747. /*
  1748. * gammal()
  1749. *
  1750. * Availability:
  1751. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1752. * CarbonLib: in CarbonLib 1.0 and later
  1753. * Mac OS X: not available
  1754. */
  1755. EXTERN_API_C( long double ) gammal(long double x);
  1756. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1757. #ifdef __cplusplus
  1758. inline DEFINE_API_C(long double ) gammal(long double x) { return (long double) gamma((double)(x)); }
  1759. #else
  1760. #define gammal(x) ((long double) gamma((double)(x)))
  1761. #endif
  1762. #endif
  1763. /*
  1764. * lgammal()
  1765. *
  1766. * Availability:
  1767. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1768. * CarbonLib: in CarbonLib 1.0 and later
  1769. * Mac OS X: not available
  1770. */
  1771. EXTERN_API_C( long double ) lgammal(long double x);
  1772. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1773. #ifdef __cplusplus
  1774. inline DEFINE_API_C(long double ) lgammal(long double x) { return (long double) lgamma((double)(x)); }
  1775. #else
  1776. #define lgammal(x) ((long double) lgamma((double)(x)))
  1777. #endif
  1778. #endif
  1779. /*
  1780. * ceill()
  1781. *
  1782. * Availability:
  1783. * Non-Carbon CFM: in MathLib 2.0 and later or as macro/inline
  1784. * CarbonLib: in CarbonLib 1.0 and later
  1785. * Mac OS X: not available
  1786. */
  1787. EXTERN_API_C( long double ) ceill(long double x);
  1788. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1789. #ifdef __cplusplus
  1790. inline DEFINE_API_C(long double ) ceill(long double x) { return (long double) ceil((double)(x)); }
  1791. #else
  1792. #define ceill(x) ((long double) ceil((double)(x)))
  1793. #endif
  1794. #endif
  1795. /*
  1796. * floorl()
  1797. *
  1798. * Availability:
  1799. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1800. * CarbonLib: in CarbonLib 1.0 and later
  1801. * Mac OS X: not available
  1802. */
  1803. EXTERN_API_C( long double ) floorl(long double x);
  1804. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1805. #ifdef __cplusplus
  1806. inline DEFINE_API_C(long double ) floorl(long double x) { return (long double) floor((double)(x)); }
  1807. #else
  1808. #define floorl(x) ((long double) floor((double)(x)))
  1809. #endif
  1810. #endif
  1811. /*
  1812. * rintl()
  1813. *
  1814. * Availability:
  1815. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1816. * CarbonLib: in CarbonLib 1.0 and later
  1817. * Mac OS X: not available
  1818. */
  1819. EXTERN_API_C( long double ) rintl(long double x);
  1820. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1821. #ifdef __cplusplus
  1822. inline DEFINE_API_C(long double ) rintl(long double x) { return (long double) rint((double)(x)); }
  1823. #else
  1824. #define rintl(x) ((long double) rint((double)(x)))
  1825. #endif
  1826. #endif
  1827. /*
  1828. * nearbyintl()
  1829. *
  1830. * Availability:
  1831. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1832. * CarbonLib: in CarbonLib 1.0 and later
  1833. * Mac OS X: not available
  1834. */
  1835. EXTERN_API_C( long double ) nearbyintl(long double x);
  1836. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1837. #ifdef __cplusplus
  1838. inline DEFINE_API_C(long double ) nearbyintl(long double x) { return (long double) nearbyint((double)(x)); }
  1839. #else
  1840. #define nearbyintl(x) ((long double) nearbyint((double)(x)))
  1841. #endif
  1842. #endif
  1843. /*
  1844. * rinttoll()
  1845. *
  1846. * Availability:
  1847. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1848. * CarbonLib: in CarbonLib 1.0 and later
  1849. * Mac OS X: not available
  1850. */
  1851. EXTERN_API_C( long ) rinttoll(long double x);
  1852. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1853. #ifdef __cplusplus
  1854. inline DEFINE_API_C(long ) rinttoll(long double x) { return rinttol((double)(x)); }
  1855. #else
  1856. #define rinttoll(x) (rinttol((double)(x)))
  1857. #endif
  1858. #endif
  1859. /*
  1860. * roundl()
  1861. *
  1862. * Availability:
  1863. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1864. * CarbonLib: in CarbonLib 1.0 and later
  1865. * Mac OS X: not available
  1866. */
  1867. EXTERN_API_C( long double ) roundl(long double x);
  1868. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1869. #ifdef __cplusplus
  1870. inline DEFINE_API_C(long double ) roundl(long double x) { return (long double) round((double)(x)); }
  1871. #else
  1872. #define roundl(x) ((long double) round((double)(x)))
  1873. #endif
  1874. #endif
  1875. /*
  1876. * roundtoll()
  1877. *
  1878. * Availability:
  1879. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1880. * CarbonLib: in CarbonLib 1.0 and later
  1881. * Mac OS X: not available
  1882. */
  1883. EXTERN_API_C( long ) roundtoll(long double x);
  1884. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1885. #ifdef __cplusplus
  1886. inline DEFINE_API_C(long ) roundtoll(long double x) { return roundtol((double)(x)); }
  1887. #else
  1888. #define roundtoll(x) (roundtol((double)(x)))
  1889. #endif
  1890. #endif
  1891. /*
  1892. * truncl()
  1893. *
  1894. * Availability:
  1895. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1896. * CarbonLib: in CarbonLib 1.0 and later
  1897. * Mac OS X: not available
  1898. */
  1899. EXTERN_API_C( long double ) truncl(long double x);
  1900. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1901. #ifdef __cplusplus
  1902. inline DEFINE_API_C(long double ) truncl(long double x) { return (long double) trunc((double)(x)); }
  1903. #else
  1904. #define truncl(x) ((long double) trunc((double)(x)))
  1905. #endif
  1906. #endif
  1907. /*
  1908. * remainderl()
  1909. *
  1910. * Availability:
  1911. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1912. * CarbonLib: in CarbonLib 1.0 and later
  1913. * Mac OS X: not available
  1914. */
  1915. EXTERN_API_C( long double ) remainderl(long double x, long double y);
  1916. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1917. #ifdef __cplusplus
  1918. inline DEFINE_API_C(long double ) remainderl(long double x, long double y) { return (long double) remainder((double)(x), (double)(y)); }
  1919. #else
  1920. #define remainderl(x, y) ((long double) remainder((double)(x), (double)(y)))
  1921. #endif
  1922. #endif
  1923. /*
  1924. * remquol()
  1925. *
  1926. * Availability:
  1927. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1928. * CarbonLib: in CarbonLib 1.0 and later
  1929. * Mac OS X: not available
  1930. */
  1931. EXTERN_API_C( long double ) remquol(long double x, long double y, int *quo);
  1932. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1933. #ifdef __cplusplus
  1934. inline DEFINE_API_C(long double ) remquol(long double x, long double y, int *quo) { return (long double) remquo((double)(x), (double)(y), (quo)); }
  1935. #else
  1936. #define remquol(x, y, quo) ((long double) remquo((double)(x), (double)(y), (quo)))
  1937. #endif
  1938. #endif
  1939. /*
  1940. * copysignl()
  1941. *
  1942. * Availability:
  1943. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1944. * CarbonLib: in CarbonLib 1.0 and later
  1945. * Mac OS X: not available
  1946. */
  1947. EXTERN_API_C( long double ) copysignl(long double x, long double y);
  1948. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1949. #ifdef __cplusplus
  1950. inline DEFINE_API_C(long double ) copysignl(long double x, long double y) { return (long double) copysign((double)(x), (double)(y)); }
  1951. #else
  1952. #define copysignl(x, y) ((long double) copysign((double)(x), (double)(y)))
  1953. #endif
  1954. #endif
  1955. /*
  1956. * fdiml()
  1957. *
  1958. * Availability:
  1959. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1960. * CarbonLib: in CarbonLib 1.0 and later
  1961. * Mac OS X: not available
  1962. */
  1963. EXTERN_API_C( long double ) fdiml(long double x, long double y);
  1964. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1965. #ifdef __cplusplus
  1966. inline DEFINE_API_C(long double ) fdiml(long double x, long double y) { return (long double) fdim((double)(x), (double)(y)); }
  1967. #else
  1968. #define fdiml(x, y) ((long double) fdim((double)(x), (double)(y)))
  1969. #endif
  1970. #endif
  1971. /*
  1972. * fmaxl()
  1973. *
  1974. * Availability:
  1975. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1976. * CarbonLib: in CarbonLib 1.0 and later
  1977. * Mac OS X: not available
  1978. */
  1979. EXTERN_API_C( long double ) fmaxl(long double x, long double y);
  1980. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1981. #ifdef __cplusplus
  1982. inline DEFINE_API_C(long double ) fmaxl(long double x, long double y) { return (long double) fmax((double)(x), (double)(y)); }
  1983. #else
  1984. #define fmaxl(x, y) ((long double) fmax((double)(x), (double)(y)))
  1985. #endif
  1986. #endif
  1987. /*
  1988. * fminl()
  1989. *
  1990. * Availability:
  1991. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  1992. * CarbonLib: in CarbonLib 1.0 and later
  1993. * Mac OS X: not available
  1994. */
  1995. EXTERN_API_C( long double ) fminl(long double x, long double y);
  1996. #if TYPE_LONGDOUBLE_IS_DOUBLE
  1997. #ifdef __cplusplus
  1998. inline DEFINE_API_C(long double ) fminl(long double x, long double y) { return (long double) fmin((double)(x), (double)(y)); }
  1999. #else
  2000. #define fminl(x, y) ((long double) fmin((double)(x), (double)(y)))
  2001. #endif
  2002. #endif
  2003. #endif /* __MWERKS__ */
  2004. #ifndef __NOEXTENSIONS__
  2005. /*
  2006. * relationl()
  2007. *
  2008. * Availability:
  2009. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  2010. * CarbonLib: in CarbonLib 1.0 and later
  2011. * Mac OS X: not available
  2012. */
  2013. EXTERN_API_C( relop ) relationl(long double x, long double y);
  2014. #if TYPE_LONGDOUBLE_IS_DOUBLE
  2015. #ifdef __cplusplus
  2016. inline DEFINE_API_C(relop ) relationl(long double x, long double y) { return relation((double)(x), (double)(y)); }
  2017. #else
  2018. #define relationl(x, y) (relation((double)(x), (double)(y)))
  2019. #endif
  2020. #endif
  2021. /*
  2022. * num2decl()
  2023. *
  2024. * Availability:
  2025. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  2026. * CarbonLib: in CarbonLib 1.0 and later
  2027. * Mac OS X: not available
  2028. */
  2029. EXTERN_API_C( void ) num2decl(const decform *f, long double x, decimal *d);
  2030. #if TYPE_LONGDOUBLE_IS_DOUBLE
  2031. #ifdef __cplusplus
  2032. inline DEFINE_API_C(void) num2decl(const decform *f, long double x, decimal *d) { num2dec((f), (double)(x), (d)); }
  2033. #else
  2034. #define num2decl(f, x, d) (num2dec((f), (double)(x), (d)))
  2035. #endif
  2036. #endif
  2037. /*
  2038. * dec2numl()
  2039. *
  2040. * Availability:
  2041. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  2042. * CarbonLib: in CarbonLib 1.0 and later
  2043. * Mac OS X: not available
  2044. */
  2045. EXTERN_API_C( long double ) dec2numl(const decimal * d);
  2046. #if TYPE_LONGDOUBLE_IS_DOUBLE
  2047. #ifdef __cplusplus
  2048. inline DEFINE_API_C(long double ) dec2numl(const decimal *d) { return (long double) dec2num(d); }
  2049. #else
  2050. #define dec2numl(d) ((long double) dec2num(d))
  2051. #endif
  2052. #endif
  2053. #endif /* !defined(__NOEXTENSIONS__) */
  2054. #endif /* TARGET_CPU_PPC */
  2055. #endif /* TARGET_OS_MAC */
  2056. #ifndef __NOEXTENSIONS__
  2057. /*
  2058. MathLib v2 has two new transfer functions: x80tod and dtox80. They can
  2059. be used to directly transform 68k 80-bit extended data types to double
  2060. and back for PowerPC based machines without using the functions
  2061. x80told or ldtox80. Double rounding may occur.
  2062. */
  2063. /*
  2064. * x80tod()
  2065. *
  2066. * Availability:
  2067. * Non-Carbon CFM: in MathLib 2.0 and later
  2068. * CarbonLib: in CarbonLib 1.0 and later
  2069. * Mac OS X: in version 10.0 and later
  2070. */
  2071. EXTERN_API_C( double ) x80tod(const extended80 * x80);
  2072. /*
  2073. * dtox80()
  2074. *
  2075. * Availability:
  2076. * Non-Carbon CFM: in MathLib 2.0 and later
  2077. * CarbonLib: in CarbonLib 1.0 and later
  2078. * Mac OS X: in version 10.0 and later
  2079. */
  2080. EXTERN_API_C( void ) dtox80(const double *x, extended80 *x80);
  2081. /*
  2082. * x80told()
  2083. *
  2084. * Availability:
  2085. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  2086. * CarbonLib: in CarbonLib 1.0 and later
  2087. * Mac OS X: not available
  2088. */
  2089. EXTERN_API_C( void ) x80told(const extended80 *x80, long double *x);
  2090. #if TYPE_LONGDOUBLE_IS_DOUBLE && !TARGET_OS_WIN32
  2091. #ifdef __cplusplus
  2092. inline DEFINE_API_C(void) x80told(const extended80 *x80, long double *x) { *(x) = (long double) x80tod(x80); }
  2093. #else
  2094. #define x80told(x80, x) (*(x) = (long double) x80tod(x80))
  2095. #endif
  2096. #endif
  2097. /*
  2098. * ldtox80()
  2099. *
  2100. * Availability:
  2101. * Non-Carbon CFM: in MathLib 1.0 and later or as macro/inline
  2102. * CarbonLib: in CarbonLib 1.0 and later
  2103. * Mac OS X: not available
  2104. */
  2105. EXTERN_API_C( void ) ldtox80(const long double *x, extended80 *x80);
  2106. #if TYPE_LONGDOUBLE_IS_DOUBLE && !TARGET_OS_WIN32
  2107. #ifdef __cplusplus
  2108. inline DEFINE_API_C(void) ldtox80(const long double *x, extended80 *x80) { double d = (double) *(x); dtox80(&d, (x80)); }
  2109. #else
  2110. #define ldtox80(x, x80) do { double d = (double) *(x); dtox80(&d, (x80)); } while (false)
  2111. #endif
  2112. #endif
  2113. #endif /* !defined(__NOEXTENSIONS__) */
  2114. #if PRAGMA_STRUCT_ALIGN
  2115. #pragma options align=reset
  2116. #elif PRAGMA_STRUCT_PACKPUSH
  2117. #pragma pack(pop)
  2118. #elif PRAGMA_STRUCT_PACK
  2119. #pragma pack()
  2120. #endif
  2121. #ifdef PRAGMA_IMPORT_OFF
  2122. #pragma import off
  2123. #elif PRAGMA_IMPORT
  2124. #pragma import reset
  2125. #endif
  2126. #ifdef __cplusplus
  2127. }
  2128. #endif
  2129. #endif /* __FP__ */