Skip to content

Commit

Permalink
most Sockets.pp definitions are inlined in SynFPCSock to avoid Lazaru…
Browse files Browse the repository at this point in the history
…s problems

(part 2/2)
  • Loading branch information
Arnaud Bouchez committed Sep 21, 2018
1 parent 49448a8 commit 563dfb4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
40 changes: 37 additions & 3 deletions SynFPCSock.pas
Expand Up @@ -98,7 +98,7 @@ interface
{$endif} {$endif}
termio, termio,
netdb, netdb,
Sockets, Sockets, // most definitions are inlined in SynFPCSock to avoid Lazarus problems with Sockets.pp
SynFPCLinux, SynFPCLinux,
{$else} {$else}
{$ifdef KYLIX3} {$ifdef KYLIX3}
Expand Down Expand Up @@ -150,6 +150,9 @@ procedure DestroySocketInterface;
PSockAddrIn6 = ^TSockAddrIn6; PSockAddrIn6 = ^TSockAddrIn6;
TSockAddrIn6 = sockets.TInetSockAddr6; TSockAddrIn6 = sockets.TInetSockAddr6;


TSockAddr = sockets.TSockAddr;
PSockAddr = sockets.PSockAddr;

const const
FIONREAD = termio.FIONREAD; FIONREAD = termio.FIONREAD;
FIONBIO = termio.FIONBIO; FIONBIO = termio.FIONBIO;
Expand All @@ -167,6 +170,10 @@ procedure DestroySocketInterface;
IP_ADD_MEMBERSHIP = sockets.IP_ADD_MEMBERSHIP; { ip_mreq; add an IP group membership } IP_ADD_MEMBERSHIP = sockets.IP_ADD_MEMBERSHIP; { ip_mreq; add an IP group membership }
IP_DROP_MEMBERSHIP = sockets.IP_DROP_MEMBERSHIP; { ip_mreq; drop an IP group membership } IP_DROP_MEMBERSHIP = sockets.IP_DROP_MEMBERSHIP; { ip_mreq; drop an IP group membership }


SHUT_RD = sockets.SHUT_RD;
SHUT_WR = sockets.SHUT_WR;
SHUT_RDWR = sockets.SHUT_RDWR;

SOL_SOCKET = sockets.SOL_SOCKET; SOL_SOCKET = sockets.SOL_SOCKET;


SO_DEBUG = sockets.SO_DEBUG; SO_DEBUG = sockets.SO_DEBUG;
Expand Down Expand Up @@ -215,7 +222,9 @@ procedure DestroySocketInterface;


{ Address families. } { Address families. }
AF_UNSPEC = 0; { unspecified } AF_UNSPEC = 0; { unspecified }
AF_LOCAL = 1;
AF_INET = 2; { internetwork: UDP, TCP, etc. } AF_INET = 2; { internetwork: UDP, TCP, etc. }
AF_UNIX = AF_LOCAL;
AF_MAX = 24; AF_MAX = 24;


{ Protocol families, same as address families for now. } { Protocol families, same as address families for now. }
Expand Down Expand Up @@ -393,7 +402,7 @@ procedure SET_LOOPBACK_ADDR6 (const a: PInAddr6);
var var
in6addr_any, in6addr_loopback : TInAddr6; in6addr_any, in6addr_loopback : TInAddr6;


{$ifdef FPC} {$ifdef FPC} // some functions inlined redirection to Sockets.pp


procedure FD_CLR(Socket: TSocket; var FDSet: TFDSet); inline; procedure FD_CLR(Socket: TSocket; var FDSet: TFDSet); inline;
function FD_ISSET(Socket: TSocket; var FDSet: TFDSet): Boolean; inline; function FD_ISSET(Socket: TSocket; var FDSet: TFDSet): Boolean; inline;
Expand All @@ -403,10 +412,15 @@ procedure FD_ZERO(var FDSet: TFDSet); inline;
function ResolveIPToName(const IP: string; Family,SockProtocol,SockType: integer): string; function ResolveIPToName(const IP: string; Family,SockProtocol,SockType: integer): string;
function ResolvePort(const Port: string; Family,SockProtocol,SockType: integer): Word; 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 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;

{$endif FPC} {$endif FPC}


const const
// we assume that the OS has IP6 compatibility // we assume that the Posix OS has IP6 compatibility
SockEnhancedApi = true; SockEnhancedApi = true;
SockWship6Api = true; SockWship6Api = true;


Expand Down Expand Up @@ -669,6 +683,26 @@ procedure FD_ZERO(var fdset: TFDSet);
fpFD_ZERO(fdset); fpFD_ZERO(fdset);
end; end;


function fpbind(s:cint; addrx: psockaddr; addrlen: tsocklen): cint;
begin
result := sockets.fpbind(s, addrx, addrlen);
end;

function fplisten(s:cint; backlog : cint): cint;
begin
result := sockets.fplisten(s, backlog);
end;

function fprecv(s:cint; buf: pointer; len: size_t; Flags: cint): ssize_t;
begin
result := sockets.fprecv(s, buf, len, Flags);
end;

function fpsend(s:cint; msg:pointer; len:size_t; flags:cint): ssize_t;
begin
result := sockets.fpsend(s, msg, len, flags);
end;

{$endif FPC} {$endif FPC}


function SizeOfVarSin(sin: TVarSin): integer; function SizeOfVarSin(sin: TVarSin): integer;
Expand Down
2 changes: 1 addition & 1 deletion SynopseCommit.inc
@@ -1 +1 @@
'1.18.4806' '1.18.4807'

0 comments on commit 563dfb4

Please sign in to comment.