Skip to content

Commit

Permalink
leverage cardinal/longword cross-compiler and cross-platform use
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud Bouchez committed May 8, 2019
1 parent d1ebeda commit b206bbd
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 22 deletions.
7 changes: 5 additions & 2 deletions SQLite3/mORMot.pas
Expand Up @@ -54886,6 +54886,7 @@ function TServiceContainer.CallBackUnRegister(const Callback: IInvokable): boole
CONST_PSEUDO_RESULT_NAME: string[6] = 'Result';
CONST_PSEUDO_SELF_NAME: string[4] = 'Self';
CONST_INTEGER_NAME: string[7] = 'Integer';
CONST_CARDINAL_NAME: string[8] = 'Cardinal';

type
/// map the stack memory layout at TInterfacedObjectFake.FakeCall()
Expand Down Expand Up @@ -56656,10 +56657,12 @@ procedure TInterfaceFactoryGenerated.AddMethod(
raise EInterfaceFactoryException.CreateUTF8('%: expect TypeInfo() at #% for %.AddMethod("%")',
[fInterfaceTypeInfo^.Name,a,self,aName]);
arg^.ArgTypeInfo := aParams[a*ARGPERARG+2].VPointer;
{$ifdef FPC} // under FPC, TypeInfo(Integer)=TypeInfo(Longint)
{$ifdef FPC} // under FPC, TypeInfo(Integer/Cardinal)=TypeInfo(LongInt/LongWord)
if arg^.ArgTypeInfo=TypeInfo(Integer) then
arg^.ArgTypeName := @CONST_INTEGER_NAME else
{$endif}
if arg^.ArgTypeInfo=TypeInfo(Cardinal) then
arg^.ArgTypeName := @CONST_CARDINAL_NAME else
{$endif FPC}
arg^.ArgTypeName := @arg^.ArgTypeInfo^.Name;
end;
end;
Expand Down
6 changes: 3 additions & 3 deletions SQLite3/mORMotReport.pas
Expand Up @@ -4186,9 +4186,9 @@ procedure TGDIPages.DrawTextAcrossColsFromCSV(var CSV: PWideChar; BackgroundColo
/// round inverted color to white or black
function clAlways(cl: TColor): TColor;
begin
if ((GetRValue(longword(cl)) * 2) +
(GetGValue(longword(cl)) * 3) +
(GetBValue(longword(cl)) * 2)) < 600 then
if ((GetRValue(cardinal(cl)) * 2) +
(GetGValue(cardinal(cl)) * 3) +
(GetBValue(cardinal(cl)) * 2)) < 600 then
result := clWhite else
result := clBlack;
end;
Expand Down
24 changes: 12 additions & 12 deletions SynFPCSock.pas
Expand Up @@ -66,7 +66,7 @@
{$define LINUX} // a Linux-based system
{$endif}

// BSD definition of scoketaddr
// BSD definition of socketaddr
{$ifdef FREEBSD}
{$DEFINE SOCK_HAS_SINLEN}
{$endif}
Expand Down Expand Up @@ -413,7 +413,7 @@ function ResolveIPToName(const IP: string; Family,SockProtocol,SockType: integer
function ResolvePort(const Port: string; Family,SockProtocol,SockType: integer): Word;

function fpbind(s:cint; addrx: psockaddr; addrlen: tsocklen): cint; inline;
function fplisten(s:cint; backlog : cint): cint; inline;
function fplisten(s:cint; backlog: cint): cint; inline;
function fprecv(s:cint; buf: pointer; len: size_t; Flags: cint): ssize_t; inline;
function fpsend(s:cint; msg:pointer; len:size_t; flags:cint): ssize_t; inline;

Expand All @@ -437,11 +437,11 @@ function fpsend(s:cint; msg:pointer; len:size_t; flags:cint): ssize_t; inline;
AF_INET: (sin_port: word;
sin_addr: TInAddr;
sin_zero: array[0..7] of Char);
AF_INET6:(sin6_port: word;
sin6_flowinfo: longword;
AF_INET6:(sin6_port: word; // see sockaddr_in6
sin6_flowinfo: cardinal;
sin6_addr: TInAddr6;
sin6_scope_id: longword);
AF_UNIX: (sun_path: array[0..{$ifdef SOCK_HAS_SINLEN}104{$else}107{$endif}] of Char);
sin6_scope_id: cardinal);
AF_UNIX: (sun_path: array[0..{$ifdef SOCK_HAS_SINLEN}103{$else}107{$endif}] of Char);
);
end;

Expand All @@ -459,11 +459,11 @@ function GetSockOpt(s: TSocket; level,optname: Integer; optval: pointer;
function SendTo(s: TSocket; Buf: pointer; len,flags: Integer; addrto: TVarSin): Integer;
function RecvFrom(s: TSocket; Buf: pointer; len,flags: Integer; var from: TVarSin): Integer;
function ntohs(netshort: word): word;
function ntohl(netlong: longword): longword;
function ntohl(netlong: cardinal): cardinal;
function Listen(s: TSocket; backlog: Integer): Integer;
function IoctlSocket(s: TSocket; cmd: DWORD; var arg: integer): Integer;
function htons(hostshort: word): word;
function htonl(hostlong: longword): longword;
function htonl(hostlong: cardinal): cardinal;
function GetSockName(s: TSocket; var name: TVarSin): Integer;
function GetPeerName(s: TSocket; var name: TVarSin): Integer;
function Connect(s: TSocket; const name: TVarSin): Integer;
Expand Down Expand Up @@ -839,7 +839,7 @@ function ntohs(netshort: word): word;
result := {$ifdef KYLIX3}LibC{$else}sockets{$endif}.ntohs(NetShort);
end;

function ntohl(netlong: longword): longword;
function ntohl(netlong: cardinal): cardinal;
begin
result := {$ifdef KYLIX3}LibC{$else}sockets{$endif}.ntohl(NetLong);
end;
Expand All @@ -862,12 +862,12 @@ function IoctlSocket(s: TSocket; cmd: DWORD; var arg: integer): Integer;

function htons(hostshort: word): word;
begin
result := {$ifdef KYLIX3}LibC{$else}sockets{$endif}.htons(Hostshort);
result := {$ifdef KYLIX3}LibC{$else}sockets{$endif}.htons(hostshort);
end;

function htonl(hostlong: longword): longword;
function htonl(hostlong: cardinal): cardinal;
begin
result := {$ifdef KYLIX3}LibC{$else}sockets{$endif}.htonl(HostLong);
result := {$ifdef KYLIX3}LibC{$else}sockets{$endif}.htonl(hostlong);
end;

function CloseSocket(s: TSocket): Integer;
Expand Down
4 changes: 2 additions & 2 deletions SynOpenSSL.pas
Expand Up @@ -146,7 +146,7 @@ TASN1_STRING = record
length: integer;
type_: integer;
data: PAnsiChar;
flags: Longword;
flags: longint;
end;
PASN1_STRING = ^TASN1_STRING;

Expand Down Expand Up @@ -174,7 +174,7 @@ TCRYPTO_dynlock_value = record

TStatLockLockCallback = procedure(Mode: integer; N: integer; _file: PAnsiChar;
Line: integer); cdecl;
TStatLockIDCallback = function: Longword; cdecl;
TStatLockIDCallback = function: longint; cdecl;
TCryptoThreadIDCallback = procedure(ID: PCRYPTO_THREADID); cdecl;
TDynLockCreateCallback = function(_file: PAnsiChar; Line: integer):
PCRYPTO_dynlock_value; cdecl;
Expand Down
2 changes: 1 addition & 1 deletion SynSMAPI.pas
Expand Up @@ -135,7 +135,7 @@ interface
/// 16 bit unsigned integer type for SMAPI
JSUint16 = Word;
/// 32 bit unsigned integer type for SMAPI
JSUInt32 = LongWord;
JSUInt32 = Cardinal;
/// 64 bit signed integer type for SMAPI
JSInt64 = Int64;
/// 64 bit unsigned integer type for SMAPI
Expand Down
2 changes: 1 addition & 1 deletion SynVirtualDataSet.pas
Expand Up @@ -729,7 +729,7 @@ TFMTBcdData = class(TPersistent)
VType: TVarType;
Reserved1, Reserved2, Reserved3: Word;
VBcd: TFMTBcdData;
Reserved4: LongWord;
Reserved4: Cardinal;
end;

class procedure TSynVirtualDataSet.BcdWrite(const aWriter: TTextWriter; const aValue);
Expand Down
2 changes: 1 addition & 1 deletion SynopseCommit.inc
@@ -1 +1 @@
'1.18.5211'
'1.18.5212'

0 comments on commit b206bbd

Please sign in to comment.