First attempt at adding support for 64-bit compilers.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1416 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
macpgmr
2011-01-01 03:24:10 +00:00
parent 365fa4655e
commit a76e4b4974
8 changed files with 80 additions and 19 deletions

View File

@ -225,10 +225,10 @@ end;
procedure Error(msg: string); procedure Error(msg: string);
function ReturnAddr: Pointer; function ReturnAddr: Pointer;
// From classes.pas // From classes.pas
{$IFNDEF CPUPOWERPC} {$IFDEF CPU86}
asm asm
MOV EAX,[EBP+4] // sysutils.pas says [EBP-4] ! MOV EAX,[EBP+4] // sysutils.pas says [EBP-4] !
{$ELSE} //Ignore for now on non-Intel. {$ELSE} //Ignore for now on non-Intel/32-bit.
begin begin
{$ENDIF} {$ENDIF}
end; end;
@ -614,7 +614,7 @@ begin
end; end;
procedure TDIBWriter.CreateDIB; procedure TDIBWriter.CreateDIB;
{$IFDEF PIXELFORMAT_TOO_SLOW} {$IFDEF PIXELFORMAT_TOO_SLOW} // LCL port: Not defined with LCL to exclude assembler.
var var
SrcColors , SrcColors ,
DstColors : WORD; DstColors : WORD;
@ -1131,14 +1131,26 @@ begin
// Move on to next column // Move on to next column
if (FDirection = 1) then if (FDirection = 1) then
begin begin
{$IFNDEF FPC}
inc(longInt(ErrorR), sizeof(TErrorTerm)); inc(longInt(ErrorR), sizeof(TErrorTerm));
inc(longInt(ErrorG), sizeof(TErrorTerm)); inc(longInt(ErrorG), sizeof(TErrorTerm));
inc(longInt(ErrorB), sizeof(TErrorTerm)); inc(longInt(ErrorB), sizeof(TErrorTerm));
{$ELSE} //Cast so safe for 64-bits.
inc(PtrUInt(ErrorR), sizeof(TErrorTerm));
inc(PtrUInt(ErrorG), sizeof(TErrorTerm));
inc(PtrUInt(ErrorB), sizeof(TErrorTerm));
{$ENDIF}
end else end else
begin begin
{$IFNDEF FPC}
dec(longInt(ErrorR), sizeof(TErrorTerm)); dec(longInt(ErrorR), sizeof(TErrorTerm));
dec(longInt(ErrorG), sizeof(TErrorTerm)); dec(longInt(ErrorG), sizeof(TErrorTerm));
dec(longInt(ErrorB), sizeof(TErrorTerm)); dec(longInt(ErrorB), sizeof(TErrorTerm));
{$ELSE}
dec(PtrUInt(ErrorR), sizeof(TErrorTerm));
dec(PtrUInt(ErrorG), sizeof(TErrorTerm));
dec(PtrUInt(ErrorB), sizeof(TErrorTerm));
{$ENDIF}
end; end;
end; end;
{$IFDEF R_PLUS} {$IFDEF R_PLUS}
@ -1635,8 +1647,13 @@ begin
begin begin
SrcScanline := DIBSource.ScanLine[Row]; SrcScanline := DIBSource.ScanLine[Row];
DstScanline := DIBResult.ScanLine[Row]; DstScanline := DIBResult.ScanLine[Row];
{$IFNDEF FPC}
Src := pointer(longInt(SrcScanLine) + Ditherer.Column*sizeof(TRGBTriple)); Src := pointer(longInt(SrcScanLine) + Ditherer.Column*sizeof(TRGBTriple));
Dst := pointer(longInt(DstScanLine) + Ditherer.Column); Dst := pointer(longInt(DstScanLine) + Ditherer.Column);
{$ELSE}
Src := pointer(PtrUInt(SrcScanLine) + Ditherer.Column*sizeof(TRGBTriple));
Dst := pointer(PtrUInt(DstScanLine) + Ditherer.Column);
{$ENDIF}
while (Ditherer.Column < Ditherer.Width) and (Ditherer.Column >= 0) do while (Ditherer.Column < Ditherer.Width) and (Ditherer.Column >= 0) do
begin begin

View File

@ -32,6 +32,7 @@
{$ifdef Win32} {$ifdef Win32}
{$O-} {optimization off} {$O-} {optimization off}
{$endif} {$endif}
{$DEFINE CPU86} // LCL port: Delphi currently only for Intel, 32-bit.
{$endif} {$endif}
{$ELSE} // LCL {$ELSE} // LCL

View File

@ -260,7 +260,11 @@ end;
constructor TgfFrame.CreateCopy(Item: TgfFrame); constructor TgfFrame.CreateCopy(Item: TgfFrame);
begin begin
inherited Create; inherited Create;
{$IFNDEF FPC}
System.Move(Item.frLeft, frLeft, DWord(@TheEnd)-DWord(@frLeft)); System.Move(Item.frLeft, frLeft, DWord(@TheEnd)-DWord(@frLeft));
{$ELSE}
System.Move(Item.frLeft, frLeft, PtrUInt(@TheEnd)-PtrUInt(@frLeft));
{$ENDIF}
IsCopy := True; IsCopy := True;
end; end;
@ -287,7 +291,11 @@ begin
inherited Create; inherited Create;
FImageWidth := Item.Width; FImageWidth := Item.Width;
FimageHeight := Item.Height; FimageHeight := Item.Height;
{$IFNDEF FPC}
System.Move(Item.FAnimated, FAnimated, DWord(@TheEnd)-DWord(@FAnimated)); System.Move(Item.FAnimated, FAnimated, DWord(@TheEnd)-DWord(@FAnimated));
{$ELSE}
System.Move(Item.FAnimated, FAnimated, PtrUInt(@TheEnd)-PtrUInt(@FAnimated));
{$ENDIF}
IsCopy := True; IsCopy := True;
Frames := TgfFrameList.Create; Frames := TgfFrameList.Create;

View File

@ -464,6 +464,7 @@ procedure OutputDebugString(lpOutputString: PChar);
function GlobalAlloc(uFlags: UINT; dwBytes: DWORD): HGLOBAL; function GlobalAlloc(uFlags: UINT; dwBytes: DWORD): HGLOBAL;
function GlobalLock(hMem: HGLOBAL): Pointer; function GlobalLock(hMem: HGLOBAL): Pointer;
function GlobalUnlock(hMem: HGLOBAL): BOOL; function GlobalUnlock(hMem: HGLOBAL): BOOL;
function GlobalFree(hMem: HGLOBAL): HGLOBAL;
function PostMessage(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): BOOL; function PostMessage(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): BOOL;
function SendMessage(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; function SendMessage(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT;
@ -499,7 +500,6 @@ function PatBlt(DC: HDC; X, Y, Width, Height: Integer; Rop: DWORD): BOOL;
function SetTextJustification(DC: HDC; BreakExtra, BreakCount: Integer): Integer; function SetTextJustification(DC: HDC; BreakExtra, BreakCount: Integer): Integer;
function GetBrushOrgEx(DC: HDC; var lppt: TPoint): BOOL; function GetBrushOrgEx(DC: HDC; var lppt: TPoint): BOOL;
function SetBrushOrgEx(DC: HDC; X, Y: Integer; PrevPt: PPoint): BOOL; function SetBrushOrgEx(DC: HDC; X, Y: Integer; PrevPt: PPoint): BOOL;
function GlobalFree(hMem: HGLOBAL): HGLOBAL;
function timeGetTime: DWORD; function timeGetTime: DWORD;
function GetTextExtentExPointW(DC: HDC; p2: PWideChar; p3, p4: Integer; function GetTextExtentExPointW(DC: HDC; p2: PWideChar; p3, p4: Integer;
p5, p6: PInteger; var p7: TSize): BOOL; p5, p6: PInteger; var p7: TSize): BOOL;
@ -562,12 +562,11 @@ begin
end; end;
function GlobalAlloc(uFlags: UINT; dwBytes: DWORD): HGLOBAL; function GlobalAlloc(uFlags: UINT; dwBytes: DWORD): HGLOBAL;
// Replace with calls to standard Clipboard methods?
begin begin
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
Result := Windows.GlobalAlloc(uFlags, dwBytes); Result := Windows.GlobalAlloc(uFlags, dwBytes);
{$ELSE} {$ELSE}
Result := THandle(GetMem(dwBytes)); Result := HGLOBAL(GetMem(dwBytes)); {Treating pointer to memory as "handle"}
{$ENDIF} {$ENDIF}
end; end;
@ -576,7 +575,7 @@ begin
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
Result := Windows.GlobalLock(hMem); Result := Windows.GlobalLock(hMem);
{$ELSE} {$ELSE}
Result := PAnsiChar(hMem); Result := Pointer(hMem); {"Handle" is pointer to memory}
{$ENDIF} {$ENDIF}
end; end;
@ -585,11 +584,20 @@ begin
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
Result := Windows.GlobalUnlock(hMem); Result := Windows.GlobalUnlock(hMem);
{$ELSE} {$ELSE}
FreeMem(Pointer(hMem));
Result := True; Result := True;
{$ENDIF} {$ENDIF}
end; end;
function GlobalFree(hMem: HGLOBAL): HGLOBAL;
begin
{$IFDEF MSWINDOWS}
Result := Windows.GlobalFree(hMem);
{$ELSE}
FreeMem(Pointer(hMem)); {"Handle" is pointer to memory}
Result := 0;
{$ENDIF}
end;
function PostMessage(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): BOOL; function PostMessage(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): BOOL;
{Use control's Perform method to force it to respond to posted message. {Use control's Perform method to force it to respond to posted message.
This doesn't work: Result := LclIntf.PostMessage(hWnd, Msg, wParam, lParam); } This doesn't work: Result := LclIntf.PostMessage(hWnd, Msg, wParam, lParam); }
@ -1014,15 +1022,6 @@ begin
{$ENDIF} {$ENDIF}
end; end;
function GlobalFree(hMem: HGLOBAL): HGLOBAL;
begin
{$IFDEF MSWINDOWS}
Result := Windows.GlobalFree(hMem);
{$ELSE}
WriteLn('GlobalFree not implemented yet');
{$ENDIF}
end;
function timeGetTime: DWORD; function timeGetTime: DWORD;
begin begin
Result := GetTickCount; Result := GetTickCount;

View File

@ -260,7 +260,11 @@ end;
constructor THorzLine.CreateCopy(AMasterList: TSectionList; T: TSectionBase); constructor THorzLine.CreateCopy(AMasterList: TSectionList; T: TSectionBase);
begin begin
inherited Create(AMasterList); inherited Create(AMasterList);
{$IFNDEF FPC}
System.Move((T as THorzline).VSize, VSize, DWord(@BkGnd)-DWord(@VSize)+Sizeof(BkGnd)); System.Move((T as THorzline).VSize, VSize, DWord(@BkGnd)-DWord(@VSize)+Sizeof(BkGnd));
{$ELSE}
System.Move((T as THorzline).VSize, VSize, PtrUInt(@BkGnd)-PtrUInt(@VSize)+Sizeof(BkGnd));
{$ENDIF}
end; end;
procedure THorzLine.CopyToClipboard; procedure THorzLine.CopyToClipboard;

View File

@ -2916,7 +2916,11 @@ end;
constructor TFormControlObj.CreateCopy(T: TFormControlObj); constructor TFormControlObj.CreateCopy(T: TFormControlObj);
begin begin
inherited Create; inherited Create;
{$IFNDEF FPC}
System.Move(T.Pos, Pos, DWord(@FControl)-DWord(@Pos)); System.Move(T.Pos, Pos, DWord(@FControl)-DWord(@Pos));
{$ELSE}
System.Move(T.Pos, Pos, PtrUInt(@FControl)-PtrUInt(@Pos));
{$ENDIF}
end; end;
destructor TFormControlObj.Destroy; destructor TFormControlObj.Destroy;
@ -4236,7 +4240,11 @@ var
begin begin
inherited CreateCopy(AMasterList, T); inherited CreateCopy(AMasterList, T);
TT := T as TBlock; TT := T as TBlock;
{$IFNDEF FPC}
System.Move(TT.MargArray, MargArray, DWord(@Converted)-DWord(@MargArray)+Sizeof(Converted)); System.Move(TT.MargArray, MargArray, DWord(@Converted)-DWord(@MargArray)+Sizeof(Converted));
{$ELSE}
System.Move(TT.MargArray, MargArray, PtrUInt(@Converted)-PtrUInt(@MargArray)+Sizeof(Converted));
{$ENDIF}
MyCell := TBlockCell.CreateCopy(AMasterList, TT.MyCell); MyCell := TBlockCell.CreateCopy(AMasterList, TT.MyCell);
MyCell.Owner := Self; MyCell.Owner := Self;
DrawList := TList.Create; DrawList := TList.Create;
@ -5531,7 +5539,11 @@ var
begin begin
inherited; inherited;
TT := T as TTableBlock; TT := T as TTableBlock;
{$IFNDEF FPC}
System.Move(TT.WidthAttr, WidthAttr, DWord(@Justify)-DWord(@WidthAttr)+Sizeof(Justify)); System.Move(TT.WidthAttr, WidthAttr, DWord(@Justify)-DWord(@WidthAttr)+Sizeof(Justify));
{$ELSE}
System.Move(TT.WidthAttr, WidthAttr, PtrUInt(@Justify)-PtrUInt(@WidthAttr)+Sizeof(Justify));
{$ENDIF}
Item := MyCell.Items[0]; Item := MyCell.Items[0];
Table := Item as ThtmlTable; Table := Item as ThtmlTable;
end; end;
@ -6104,7 +6116,11 @@ BitmapList := T.BitmapList; {same list}
InlineList := T.InlineList; {same list} InlineList := T.InlineList; {same list}
IsCopy := True; IsCopy := True;
inherited CreateCopy(Self, T); inherited CreateCopy(Self, T);
{$IFNDEF FPC}
System.Move(T.ShowImages, ShowImages, DWord(@Background)-Dword(@ShowImages)+Sizeof(integer)); System.Move(T.ShowImages, ShowImages, DWord(@Background)-Dword(@ShowImages)+Sizeof(integer));
{$ELSE}
System.Move(T.ShowImages, ShowImages, PtrUInt(@Background)-PtrUInt(@ShowImages)+Sizeof(integer));
{$ENDIF}
BitmapName := ''; BitmapName := '';
BackgroundBitmap := Nil; BackgroundBitmap := Nil;
BackgroundMask := Nil; BackgroundMask := Nil;
@ -7129,7 +7145,11 @@ constructor TCellObj.CreateCopy(AMasterList: TSectionList; T: TCellObj);
begin begin
inherited create; inherited create;
Cell := TCellObjCell.CreateCopy(AMasterList, T.Cell); Cell := TCellObjCell.CreateCopy(AMasterList, T.Cell);
{$IFNDEF FPC}
Move(T.ColSpan, ColSpan, DWord(@Cell)-DWord(@ColSpan)); Move(T.ColSpan, ColSpan, DWord(@Cell)-DWord(@ColSpan));
{$ELSE}
Move(T.ColSpan, ColSpan, PtrUInt(@Cell)-PtrUInt(@ColSpan));
{$ENDIF}
if AMasterList.PrintTableBackground then if AMasterList.PrintTableBackground then
begin begin
@ -7835,7 +7855,11 @@ for I := 0 to ThtmlTable(T).Rows.Count-1 do
Rows.Add(TCellList.CreateCopy(AMasterList, TCellList(ThtmlTable(T).Rows.Items[I]))); Rows.Add(TCellList.CreateCopy(AMasterList, TCellList(ThtmlTable(T).Rows.Items[I])));
Move((T as ThtmlTable).ListsProcessed, ListsProcessed, Move((T as ThtmlTable).ListsProcessed, ListsProcessed,
{$IFNDEF FPC}
DWord(@EndList)-DWord(@ListsProcessed)); DWord(@EndList)-DWord(@ListsProcessed));
{$ELSE}
PtrUInt(@EndList)-PtrUInt(@ListsProcessed));
{$ENDIF}
SetLength(Widths, NumCols); SetLength(Widths, NumCols);
SetLength(MaxWidths, NumCols); SetLength(MaxWidths, NumCols);

View File

@ -498,7 +498,7 @@ type
var var
DC: HDC; DC: HDC;
{$IFNDEF CPUPOWERPC} {$IFDEF CPU86}
{----------------StrLenW} {----------------StrLenW}
function StrLenW(Str: PWideChar): Cardinal; function StrLenW(Str: PWideChar): Cardinal;
{returns number of characters in a string excluding the null terminator} {returns number of characters in a string excluding the null terminator}
@ -818,7 +818,7 @@ else
end; end;
end; end;
{$IFNDEF CPUPOWERPC} {$IFDEF CPU86}
function IntMin(A, B: Integer): Integer; function IntMin(A, B: Integer): Integer;
asm asm
cmp edx, eax cmp edx, eax
@ -3469,7 +3469,11 @@ begin
end; end;
Inc(x); Inc(x);
end; // scan every sample byte of the image end; // scan every sample byte of the image
{$IFNDEF FPC}
Inc(Integer(ScanLinePtr), ScanLineInc); Inc(Integer(ScanLinePtr), ScanLineInc);
{$ELSE}
Inc(ScanLinePtr, ScanLineInc); // LCL port: removed cast for 64-bits.
{$ENDIF}
end; end;
{ need to call ExCreateRegion one more time because we could have left } { need to call ExCreateRegion one more time because we could have left }
{ a RgnData with less than 2000 rects, so it wasn't yet created/combined } { a RgnData with less than 2000 rects, so it wasn't yet created/combined }

View File

@ -327,7 +327,11 @@ case LoadStyle of
end; end;
else Result := #0; {to prevent warning msg} else Result := #0; {to prevent warning msg}
end; end;
{$IFNDEF FPC}
if (Integer(Buff) and $FFF = 0) {about every 4000 chars} if (Integer(Buff) and $FFF = 0) {about every 4000 chars}
{$ELSE}
if (PtrUInt(Buff) and $FFF = 0) {about every 4000 chars}
{$ENDIF}
and not LinkSearch and Assigned(MasterList) and (DocS <> '') then and not LinkSearch and Assigned(MasterList) and (DocS <> '') then
ThtmlViewer(CallingObject).htProgress(((Buff-PChar(DocS)) *MasterList.ProgressStart) div (BuffEnd-PChar(DocS))); ThtmlViewer(CallingObject).htProgress(((Buff-PChar(DocS)) *MasterList.ProgressStart) div (BuffEnd-PChar(DocS)));
end; end;