math.inc 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. {
  2. Implementation of mathematical routines for x86_64
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2005 by the Free Pascal development team
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {****************************************************************************
  12. Floating point type routines
  13. ****************************************************************************}
  14. {$ifndef FPC_SYSTEM_HAS_ABS}
  15. {$define FPC_SYSTEM_HAS_ABS}
  16. function fpc_abs_real(d : ValReal) : ValReal;compilerproc;
  17. begin
  18. { Function is handled internal in the compiler }
  19. runerror(207);
  20. result:=0;
  21. end;
  22. {$endif FPC_SYSTEM_HAS_ABS}
  23. {$ifndef FPC_SYSTEM_HAS_SQR}
  24. {$define FPC_SYSTEM_HAS_SQR}
  25. function fpc_sqr_real(d : ValReal) : ValReal;compilerproc;
  26. begin
  27. { Function is handled internal in the compiler }
  28. runerror(207);
  29. result:=0;
  30. end;
  31. {$endif FPC_SYSTEM_HAS_SQR}
  32. {$ifndef FPC_SYSTEM_HAS_SQRT}
  33. {$define FPC_SYSTEM_HAS_SQRT}
  34. function fpc_sqrt_real(d : ValReal) : ValReal;compilerproc;
  35. begin
  36. { Function is handled internal in the compiler }
  37. runerror(207);
  38. result:=0;
  39. end;
  40. {$endif FPC_SYSTEM_HAS_SQRT}
  41. {$ifndef FPC_SYSTEM_HAS_INT}
  42. {$define FPC_SYSTEM_HAS_INT}
  43. function fpc_int_real(d : ValReal) : ValReal;assembler;nostackframe;compilerproc;
  44. asm
  45. { round as floating point towards zero }
  46. frintz d0,d0
  47. end;
  48. {$endif FPC_SYSTEM_HAS_INT}
  49. {$ifndef FPC_SYSTEM_HAS_TRUNC}
  50. {$define FPC_SYSTEM_HAS_TRUNC}
  51. function fpc_trunc_real(d : ValReal) : int64;assembler;nostackframe;compilerproc;
  52. asm
  53. { round to signed integer towards zero }
  54. fcvtzs x0,d0
  55. end;
  56. {$endif FPC_SYSTEM_HAS_TRUNC}
  57. {$ifndef FPC_SYSTEM_HAS_ROUND}
  58. {$define FPC_SYSTEM_HAS_ROUND}
  59. function fpc_round_real(d : ValReal) : int64;assembler;nostackframe;compilerproc;
  60. asm
  61. { round as floating point using current rounding mode }
  62. frintx d0,d0
  63. { convert to signed integer rounding towards zero (there's no "round to
  64. integer using current rounding mode") }
  65. fcvtzs x0,d0
  66. end;
  67. {$endif FPC_SYSTEM_HAS_ROUND}