unit Int64Em;

{
  Inno Setup
  Copyright (C) 1997-2004 Jordan Russell
  Portions by Martijn Laan
  For conditions of distribution and use, see LICENSE.TXT.

  Declaration of the Integer64 type - which represents an *unsigned* 64-bit
  integer value - and functions for manipulating Integer64's.
  (We can't use the Int64 type since it's only available in Delphi 4 and
  later.)

  $jrsoftware: issrc/Projects/Int64Em.pas,v 1.9 2004/11/07 19:23:06 jr Exp $

  Modified for InnoUnp: make use of UInt64.
}

interface

type
  Integer64 = packed record
    Lo, Hi: Longword;
  end;

{$IFDEF WIN64}
type
  // Required because otherwise I won't get type information for the D4 field.
  TGUID = record
    D1: Cardinal;
    D2: Word;
    D3: Word;
    D4: Integer64;
  end;
{$ENDIF}

function Compare64(const N1, N2: Integer64): Integer;
procedure Inc64(var X: Integer64; N: LongWord);
procedure Dec64(var X: Integer64; N: LongWord);

implementation

uses
  SysUtils, DelphiCompat;

function Compare64(const N1, N2: Integer64): Integer;
{ If N1 = N2, returns 0.
  If N1 > N2, returns 1.
  If N1 < N2, returns -1. }
begin
  if UInt64(N1) < UInt64(N2) then
    Result := -1
  else if UInt64(N1) > UInt64(N2) then
    Result := 1
  else
    Result := 0;
end;

procedure Inc64(var X: Integer64; N: LongWord);
begin
  Inc(UInt64(X), N);
end;

procedure Dec64(var X: Integer64; N: LongWord);
begin
  Dec(UInt64(X), N);
end;

end.
