Difference between revisions of "Talk:Writing portable code regarding the processor architecture"

From Free Pascal wiki
Jump to navigationJump to search
Line 24: Line 24:
 
end;  
 
end;  
  
In a AMD64 machine? How much? I do not have a AMD64 to test, snif...--[[User:Wanderlan|Wanderlan]] 20:54, 8 Feb 2005 (CET)
+
In a AMD64 machine, using FPC for Linux64? How much? I do not have a AMD64 to test, snif...--[[User:Wanderlan|Wanderlan]] 20:54, 8 Feb 2005 (CET)

Revision as of 20:59, 8 February 2005

To keep the coherence of the Pascal language it would be better to change the size of Integer and Cardinal for 64 bits, as it happened when of the sprouting of Delphi 2 and as recommends Delphi 7 help: "The generic integer types are Integer and Cardinal; use these whenever possible, since they result in the best performance for the underlying CPU and operating system." In Delphi 1 Integer had 16 bits. The other integer types are called fundamental integer types (Shortint, Smallint, Longint, Int64, Byte, Word, and Longword) and they do not have to change of size between different compiler implementations. To facilitate the transition of codes of 32 for 64 bit it would be better to create new a directive one. For example: {$IntegerHas32bit ON} as interin solution. To complete it would be interesting to create a new type UInt64 instead of the strangers PtrInt and PtrUInt. Remembering that the 64 bit compiler cannot accept the construction longint(pointer(p)), but it must give to the message "Invalid type cast" --Wanderlan 15:42, 8 Feb 2005 (CET)

Ever tried sizeof(int) in C on 64 bit systems? On most 64 bit systems int is 32 bit. Simply because int is faster :) So PtrInt and PtrUInt are usefull. --FPK 16:04, 8 Feb 2005 (CET)

Saddly it does not have a decent standardization for Pascal, norms ISO 7185 and 10206 had not followed the evolution of the use of the Pascal and are omissive for this case! A valid way is the one that you are adopting, to use "C"isms or better "GCC"isms to evolve the language, particularly I think inelegant (ok, in true, I think very ugly), but you are the architect :) Another one would be to follow an eventual Delphi 64, that nobody knows that standard will adopt. In this in case that it is easy to adjust the FPC in the future, it is enough to place this standard in directive {$Mode Delphi} ;} --Wanderlan 20:40, 8 Feb 2005 (CET)

I was with a doubt. The code:

var

 I64, J64: Int64;

begin

 J64: = 0; 
 for I64 := 0 to MaxInt do inc(J64);

end;

Is it slower than:

var

 I32, J32: Integer;

begin

 J32: = 0; 
 for I32 := 0 to MaxInt do inc(J32);

end;

In a AMD64 machine, using FPC for Linux64? How much? I do not have a AMD64 to test, snif...--Wanderlan 20:54, 8 Feb 2005 (CET)