2
This file is part of the Free Pascal run time library.
3
Copyright (c) 1999-2001 by Several contributors
5
Generic mathemtical routines in libc
7
See the file COPYING.FPC, included in this distribution,
8
for details about the copyright.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
**********************************************************************}
16
{ for 80x86, we can easily write the optimal inline code }
21
{$ifndef FPC_SYSTEM_HAS_INT}
22
{$define FPC_SYSTEM_HAS_INT}
24
{$ifdef SUPPORT_DOUBLE}
25
function c_trunc(d: double): double; cdecl; external 'c' name 'trunc';
27
function fpc_int_real(d: ValReal): ValReal;compilerproc; {$ifdef MATHINLINE}inline;{$endif}
33
{$else SUPPORT_DOUBLE}
35
function c_truncf(d: double): double; cdecl; external 'c' name 'truncf';
37
function fpc_int_real(d: ValReal): ValReal;compilerproc; {$ifdef MATHINLINE}inline;{$endif}
39
{ this will be correct since real = single in the case of }
40
{ the motorola version of the compiler... }
43
{$endif SUPPORT_DOUBLE}
45
{$endif FPC_SYSTEM_HAS_INT}
48
{$ifndef SYSTEM_HAS_FREXP}
49
{$define SYSTEM_HAS_FREXP}
50
function c_frexp(x: double; out e: longint): double; cdecl; external 'c' name 'frexp';
52
function frexp(x:ValReal; out e:Integer ):ValReal; {$ifdef MATHINLINE}inline;{$endif}
56
frexp := c_frexp(x,l);
59
{$endif not SYSTEM_HAS_FREXP}
62
{$ifndef SYSTEM_HAS_LDEXP}
63
{$define SYSTEM_HAS_LDEXP}
64
function c_ldexp(x: double; n: longint): double; cdecl; external 'c' name 'ldexp';
66
function ldexp( x: ValReal; N: Integer):ValReal;{$ifdef MATHINLINE}inline;{$endif}
68
ldexp := c_ldexp(x,n);
70
{$endif not SYSTEM_HAS_LDEXP}
73
{$ifndef FPC_SYSTEM_HAS_SQRT}
74
{$define FPC_SYSTEM_HAS_SQRT}
76
function c_sqrt(d: double): double; cdecl; external 'c' name 'sqrt';
78
function fpc_sqrt_real(d:ValReal):ValReal;compilerproc; {$ifdef MATHINLINE}inline;{$endif}
86
{$ifndef FPC_SYSTEM_HAS_EXP}
87
{$define FPC_SYSTEM_HAS_EXP}
88
function c_exp(d: double): double; cdecl; external 'c' name 'exp';
90
function fpc_Exp_real(d:ValReal):ValReal;compilerproc; {$ifdef MATHINLINE}inline;{$endif}
97
{ Not supported everywhere (also not on Mac OS X 10.1, but that's deprecated. }
98
{ It is supported on linux, but at least for linux/i386 we should call }
99
{ llroundl() instead (for extended support). }
101
{$if defined(darwin) }
103
{$ifndef FPC_SYSTEM_HAS_ROUND}
104
{$define FPC_SYSTEM_HAS_ROUND}
106
function c_llround(d: double): int64; cdecl; external 'c' name 'llround';
108
// function round(d : Real) : int64; external name 'FPC_ROUND';
110
function fpc_round_real(d : ValReal) : int64;[public, alias:'FPC_ROUND'];compilerproc;
112
fpc_round_real := c_llround(d);
114
{$endif not FPC_SYSTEM_HAS_ROUND}
119
{$ifndef FPC_SYSTEM_HAS_LN}
120
{$define FPC_SYSTEM_HAS_LN}
122
function c_log(d: double): double; cdecl; external 'c' name 'log';
124
function fpc_Ln_real(d:ValReal):ValReal;compilerproc;{$ifdef MATHINLINE}inline;{$endif}
131
{$ifndef FPC_SYSTEM_HAS_SIN}
132
{$define FPC_SYSTEM_HAS_SIN}
133
function c_sin(d: double): double; cdecl; external 'c' name 'sin';
135
function fpc_Sin_real(d:ValReal):ValReal;compilerproc; {$ifdef MATHINLINE}inline;{$endif}
143
{$ifndef FPC_SYSTEM_HAS_COS}
144
{$define FPC_SYSTEM_HAS_COS}
145
function c_cos(d: double): double; cdecl; external 'c' name 'cos';
147
function fpc_Cos_real(d:ValReal):ValReal;compilerproc; {$ifdef MATHINLINE}inline;{$endif}
155
{$ifndef FPC_SYSTEM_HAS_ARCTAN}
156
{$define FPC_SYSTEM_HAS_ARCTAN}
157
function c_atan(d: double): double; cdecl; external 'c' name 'atan';
159
function fpc_ArcTan_real(d:ValReal):ValReal;compilerproc; {$ifdef MATHINLINE}inline;{$endif}