* ValSInt fixed for 64 bit

This commit is contained in:
peter 2004-05-01 20:52:50 +00:00
parent 6d19671a84
commit b5df63e617
5 changed files with 95 additions and 51 deletions

View File

@ -210,8 +210,10 @@ Procedure fpc_Read_Text_Char(var f : Text; var c : char); compilerproc;
Procedure fpc_Read_Text_SInt(var f : Text; var l :ValSInt); compilerproc;
Procedure fpc_Read_Text_UInt(var f : Text; var u :ValUInt); compilerproc;
Procedure fpc_Read_Text_Float(var f : Text; var v :ValReal); compilerproc;
{$ifndef CPU64}
Procedure fpc_Read_Text_QWord(var f : text; var q : qword); compilerproc;
Procedure fpc_Read_Text_Int64(var f : text; var i : int64); compilerproc;
{$endif CPU64}
{$ifdef FPC_INCLUDE_SOFTWARE_MOD_DIV}
function fpc_div_dword(n,z : dword) : dword; compilerproc;
@ -328,7 +330,10 @@ function fpc_qword_to_double(q: qword): double; compilerproc;
{
$Log$
Revision 1.54 2004-04-29 19:50:13 peter
Revision 1.55 2004-05-01 20:52:50 peter
* ValSInt fixed for 64 bit
Revision 1.54 2004/04/29 19:50:13 peter
* x86-64 fixes
Revision 1.53 2004/04/29 18:59:43 peter

View File

@ -1150,6 +1150,66 @@ end;
{$endif ndef FPC_SYSTEM_HAS_INT_STR_LONGWORD}
{$ifndef FPC_SYSTEM_HAS_INT_STR_INT64}
procedure int_str(l : int64;var s : string);
var
value: int64;
negative: boolean;
begin
negative := false;
s:='';
{ Workaround: }
if l=int64($8000000000000000) then
begin
s:='-9223372036854775808';
exit;
end;
{ handle case where l = 0 }
if l = 0 then
begin
s:='0';
exit;
end;
If l < 0 then
begin
negative := true;
value:=abs(l);
end
else
value:=l;
{ handle non-zero case }
while value>0 do
begin
s:=char((value mod 10)+ord('0'))+s;
value := value div 10;
end;
if negative then
s := '-' + s;
end;
{$endif ndef FPC_SYSTEM_HAS_INT_STR_INT64}
{$ifndef FPC_SYSTEM_HAS_INT_STR_QWORD}
procedure int_str(l : qword;var s : string);
begin
s:='';
if l = 0 then
begin
s := '0';
exit;
end;
while l>0 do
begin
s:=char(ord('0')+(l mod 10))+s;
l:=l div 10;
end;
end;
{$endif ndef FPC_SYSTEM_HAS_INT_STR_QWORD}
{$ifndef FPC_SYSTEM_HAS_SYSRESETFPU}
procedure SysResetFpu;
@ -1161,7 +1221,10 @@ end;
{
$Log$
Revision 1.74 2004-05-01 15:26:33 jonas
Revision 1.75 2004-05-01 20:52:50 peter
* ValSInt fixed for 64 bit
Revision 1.74 2004/05/01 15:26:33 jonas
* use some more string routines from libc if FPC_USE_LIBC is used
Revision 1.73 2004/04/29 19:50:13 peter

View File

@ -378,40 +378,17 @@ end;
{$ifndef CPU64}
procedure int_qword_str(value : qword;var s : string);
var
hs : string;
begin
hs:='';
repeat
hs:=chr(longint(value mod qword(10))+48)+hs;
value:=value div qword(10);
until value=0;
s:=hs;
end;
procedure fpc_shortstr_qword(v : qword;len : longint;var s : shortstring);[public,alias:'FPC_SHORTSTR_QWORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
begin
int_qword_str(v,s);
int_str(v,s);
if length(s)<len then
s:=space(len-length(s))+s;
end;
procedure fpc_shortstr_int64(v : int64;len : longint;var s : shortstring);[public,alias:'FPC_SHORTSTR_INT64']; {$ifdef hascompilerproc} compilerproc; {$endif}
var
hs : shortstring;
q : qword;
begin
if v<0 then
begin
q:=qword(-v);
int_qword_str(q,hs);
s:='-'+hs;
end
else
int_qword_str(qword(v),s);
int_str(v,s);
if length(s)<len then
s:=space(len-length(s))+s;
end;
@ -482,7 +459,7 @@ var
ss : shortstring;
maxlen : StrLenInt;
begin
int_qword_str(v,ss);
int_str(v,ss);
if length(ss)<len then
ss:=space(len-length(ss))+ss;
if length(ss)<high(a)+1 then
@ -497,16 +474,8 @@ procedure fpc_chararray_int64(v : int64;len : StrLenInt;var a : array of char);{
var
ss : shortstring;
maxlen : StrLenInt;
q : qword;
begin
if v<0 then
begin
q:=qword(-v);
int_qword_str(q,ss);
ss:='-'+ss;
end
else
int_qword_str(qword(v),ss);
int_str(v,ss);
if length(ss)<len then
ss:=space(len-length(ss))+ss;
if length(ss)<high(a)+1 then
@ -893,7 +862,10 @@ end;
{
$Log$
Revision 1.28 2004-04-29 18:59:43 peter
Revision 1.29 2004-05-01 20:52:50 peter
* ValSInt fixed for 64 bit
Revision 1.28 2004/04/29 18:59:43 peter
* str() helpers now also use valint/valuint
* int64/qword helpers disabled for cpu64

View File

@ -94,8 +94,6 @@ Type
{$define SUPPORT_EXTENDED}
{$define SUPPORT_COMP}
ValSInt = Longint;
ValUInt = Cardinal;
ValReal = Extended;
{$endif CPUI386}
@ -107,14 +105,10 @@ Type
{$define SUPPORT_EXTENDED}
{$define SUPPORT_COMP}
ValSInt = Longint;
ValUInt = Cardinal;
ValReal = Extended;
{$endif CPUX86_64}
{$ifdef CPUM68K}
ValSInt = Longint;
ValUInt = Cardinal;
ValReal = Real;
{ Comp type does not exist on fpu }
@ -139,8 +133,6 @@ Type
{$define FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE}
ValSInt = Longint;
ValUInt = Cardinal;
ValReal = Double;
{ map comp to int64, but this doesn't mean we compile the comp support in! }
@ -154,8 +146,6 @@ Type
{$define SUPPORT_SINGLE}
{$define SUPPORT_DOUBLE}
ValSInt = Longint;
ValUInt = Cardinal;
ValReal = Double;
{ map comp to int64, but this doesn't mean we compile the comp support in! }
@ -189,6 +179,8 @@ Type
SizeUInt = QWord;
PtrInt = Int64;
PtrUInt = QWord;
ValSInt = int64;
ValUInt = qword;
{$endif CPU64}
{$ifdef CPU32}
@ -198,6 +190,8 @@ Type
SizeUInt = DWord;
PtrInt = Longint;
PtrUInt = DWord;
ValSInt = Longint;
ValUInt = Cardinal;
{$endif CPU32}
{ Zero - terminated strings }
@ -737,7 +731,10 @@ const
{
$Log$
Revision 1.89 2004-04-29 18:59:43 peter
Revision 1.90 2004-05-01 20:52:50 peter
* ValSInt fixed for 64 bit
Revision 1.89 2004/04/29 18:59:43 peter
* str() helpers now also use valint/valuint
* int64/qword helpers disabled for cpu64

View File

@ -1011,7 +1011,7 @@ Function fpc_Read_Text_SInt(var f : Text):ValSInt;[Public,Alias:'FPC_READ_TEXT_S
{$endif hascompilerproc}
var
hs : String;
code : Longint;
code : longint;
Begin
{$ifdef hascompilerproc}
l:=0;
@ -1148,6 +1148,8 @@ begin
end;
{$ifndef cpu64}
{$ifdef hascompilerproc}
procedure fpc_Read_Text_QWord(var f : text; var q : qword); iocheck; [public,alias:'FPC_READ_TEXT_QWORD']; compilerproc;
{$else hascompilerproc}
@ -1242,6 +1244,8 @@ Begin
InOutRes:=106;
End;
{$endif CPU64}
{*****************************************************************************
Initializing
@ -1269,7 +1273,10 @@ end;
{
$Log$
Revision 1.22 2004-04-29 18:59:43 peter
Revision 1.23 2004-05-01 20:52:50 peter
* ValSInt fixed for 64 bit
Revision 1.22 2004/04/29 18:59:43 peter
* str() helpers now also use valint/valuint
* int64/qword helpers disabled for cpu64