mathh.inc 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by Florian Klaempfl,
  5. member of the Free Pascal development team
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. { i386 FPU Controlword }
  13. {$ifdef cpui386}
  14. const
  15. Default8087CW : word = $1332;
  16. procedure Set8087CW(cw:word);
  17. function Get8087CW:word;
  18. {$endif cpui386}
  19. {$ifdef cpux86_64}
  20. const
  21. Default8087CW : word = $1332;
  22. procedure Set8087CW(cw:word);
  23. function Get8087CW:word;
  24. {$endif cpux86_64}
  25. { declarations of the math routines }
  26. {$ifdef cpui386}
  27. {$define INTERNMATH}
  28. {$endif}
  29. {$ifndef INTERNMATH}
  30. {$ifdef FPC_USE_LIBC}
  31. {$ifdef SYSTEMINLINE}
  32. {$define MATHINLINE}
  33. {$endif}
  34. {$endif}
  35. {$endif}
  36. {$ifdef internconstintf}
  37. function pi : ValReal;[internproc:fpc_in_pi_real];
  38. function abs(d : ValReal) : ValReal;[internproc:fpc_in_abs_real];
  39. function sqr(d : ValReal) : ValReal;[internproc:fpc_in_sqr_real];
  40. function sqrt(d : ValReal) : ValReal;[internproc:fpc_in_sqrt_real];
  41. function arctan(d : ValReal) : ValReal;[internproc:fpc_in_arctan_real];
  42. function ln(d : ValReal) : ValReal;[internproc:fpc_in_ln_real];
  43. function sin(d : ValReal) : ValReal;[internproc:fpc_in_sin_real];
  44. function cos(d : ValReal) : ValReal;[internproc:fpc_in_cos_real];
  45. function exp(d : ValReal) : ValReal;[internproc:fpc_in_exp_real];
  46. function round(d : ValReal) : int64;[internproc:fpc_in_round_real];
  47. function frac(d : ValReal) : ValReal;[internproc:fpc_in_frac_real];
  48. function int(d : ValReal) : ValReal;[internproc:fpc_in_int_real];
  49. function trunc(d : ValReal) : int64;[internproc:fpc_in_trunc_real];
  50. {$else}
  51. function abs(d : ValReal) : ValReal;
  52. function arctan(d : ValReal) : ValReal;{$ifdef MATHINLINE}inline;{$endif}
  53. function cos(d : ValReal) : ValReal;{$ifdef MATHINLINE}inline;{$endif}
  54. function exp(d : ValReal) : ValReal;{$ifdef MATHINLINE}inline;{$endif}
  55. function frac(d : ValReal) : ValReal;
  56. function int(d : ValReal) : ValReal;{$ifdef MATHINLINE}inline;{$endif}
  57. function ln(d : ValReal) : ValReal;{$ifdef MATHINLINE}inline;{$endif}
  58. function pi : ValReal;
  59. function sin(d : ValReal) : ValReal;{$ifdef MATHINLINE}inline;{$endif}
  60. function sqr(d : ValReal) : ValReal;
  61. function sqrt(d : ValReal) : ValReal;{$ifdef MATHINLINE}inline;{$endif}
  62. function round(d : ValReal) : int64;
  63. function trunc(d : ValReal) : int64;
  64. {$endif internconstintf}
  65. {$ifdef FPC_CURRENCY_IS_INT64}
  66. function trunc(c : currency) : int64;
  67. function trunc(c : comp) : int64;
  68. function round(c : currency) : int64;
  69. function round(c : comp) : int64;
  70. {$endif FPC_CURRENCY_IS_INT64}
  71. type
  72. real48 = array[0..5] of byte;
  73. {$ifdef SUPPORT_DOUBLE}
  74. function Real2Double(r : real48) : double;
  75. operator := (b:real48) d:double;
  76. {$endif}
  77. {$ifdef SUPPORT_EXTENDED}
  78. operator := (b:real48) e:extended;
  79. {$endif SUPPORT_EXTENDED}
  80. {
  81. $Log$
  82. Revision 1.21 2005-02-08 20:25:28 florian
  83. - killed power from system unit
  84. * move operator ** to math unit
  85. Revision 1.20 2004/12/02 08:11:22 marco
  86. * patch from peter.
  87. Revision 1.19 2004/11/21 15:35:23 peter
  88. * float routines all use internproc and compilerproc helpers
  89. Revision 1.18 2004/11/18 10:03:36 michael
  90. + Patch from peter to fix pasjpeg compile
  91. Revision 1.17 2004/11/17 22:19:04 peter
  92. internconst, internproc and some external declarations moved to interface
  93. Revision 1.16 2004/10/09 21:00:46 jonas
  94. + cgenmath with libc math functions. Faster than the routines in genmath
  95. and also have full double support (exp() only has support for values in
  96. the single range in genmath, for example). Used in FPC_USE_LIBC is
  97. defined
  98. * several fixes to allow compilation with -dHASINLINE, but internalerrors
  99. because of missing support for inlining assembler code
  100. Revision 1.15 2004/02/08 15:33:50 florian
  101. * linking problems fixed
  102. + abi tag added
  103. Revision 1.14 2004/01/02 17:19:04 jonas
  104. * if currency = int64, FPC_CURRENCY_IS_INT64 is defined
  105. + round and trunc for currency and comp if FPC_CURRENCY_IS_INT64 is
  106. defined
  107. * if currency = orddef, prefer currency -> int64/qword conversion over
  108. currency -> float conversions
  109. * optimized currency/currency if currency = orddef
  110. * TODO: write FPC_DIV_CURRENCY and FPC_MUL_CURRENCY routines to prevent
  111. precision loss if currency=int64 and bestreal = double
  112. Revision 1.13 2003/01/21 19:36:36 mazen
  113. - fpc_int64_to_double removed as not supported by most cpu targets
  114. Revision 1.12 2003/01/20 22:21:36 mazen
  115. * many stuff related to RTL fixed
  116. Revision 1.11 2003/01/15 00:40:18 peter
  117. * power returns int64
  118. Revision 1.10 2003/01/03 20:34:02 peter
  119. * i386 fpu controlword functions added
  120. Revision 1.9 2002/10/06 21:26:18 peter
  121. * round returns int64
  122. Revision 1.8 2002/09/07 15:07:45 peter
  123. * old logs removed and tabs fixed
  124. Revision 1.7 2002/07/26 22:46:06 florian
  125. * interface of system unit for Linux/PowerPC compiles
  126. }