mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2026-01-06 02:50:44 +01:00
* add preliminary UnixSockets with linux implementation
git-svn-id: trunk@8290 -
This commit is contained in:
parent
a01b377e40
commit
7a21cb5888
3
.gitattributes
vendored
3
.gitattributes
vendored
@ -4812,6 +4812,8 @@ rtl/linux/termio.pp svneol=native#text/plain
|
||||
rtl/linux/termios.inc svneol=native#text/plain
|
||||
rtl/linux/termiosproc.inc svneol=native#text/plain
|
||||
rtl/linux/unixsock.inc svneol=native#text/plain
|
||||
rtl/linux/unixsockets.inc svneol=native#text/plain
|
||||
rtl/linux/unixsocketsh.inc svneol=native#text/plain
|
||||
rtl/linux/unxconst.inc svneol=native#text/plain
|
||||
rtl/linux/unxfunc.inc svneol=native#text/plain
|
||||
rtl/linux/unxsockh.inc svneol=native#text/plain
|
||||
@ -5411,6 +5413,7 @@ rtl/unix/timezone.inc svneol=native#text/plain
|
||||
rtl/unix/tthread.inc svneol=native#text/plain
|
||||
rtl/unix/ttyname.inc svneol=native#text/plain
|
||||
rtl/unix/unix.pp svneol=native#text/plain
|
||||
rtl/unix/unixsockets.pas svneol=native#text/plain
|
||||
rtl/unix/unixtype.pp svneol=native#text/plain
|
||||
rtl/unix/unixutil.pp svneol=native#text/plain
|
||||
rtl/unix/unxdeclh.inc svneol=native#text/plain
|
||||
|
||||
34
rtl/linux/unixsockets.inc
Normal file
34
rtl/linux/unixsockets.inc
Normal file
@ -0,0 +1,34 @@
|
||||
|
||||
function CMSG_FIRSTHDR(mhdr: Pmsghdr): Pcmsghdr;
|
||||
begin
|
||||
if mhdr^.msg_controllen >= SizeOf(cmsghdr) then
|
||||
Result:=mhdr^.msg_control
|
||||
else
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
function CMSG_NXTHDR(mhdr: Pmsghdr; cmsg: Pcmsghdr): Pcmsghdr;
|
||||
begin
|
||||
Result:=__cmsg_nxthdr(mhdr, cmsg);
|
||||
end;
|
||||
|
||||
function CMSG_ALIGN(len: size_t): size_t;
|
||||
begin
|
||||
Result:=(len+SizeOf(size_t)-1) and (not(SizeOf(size_t)-1));
|
||||
end;
|
||||
|
||||
function CMSG_SPACE(len: size_t): size_t;
|
||||
begin
|
||||
Result:=CMSG_ALIGN(len)+CMSG_ALIGN(SizeOf(cmsghdr));
|
||||
end;
|
||||
|
||||
function CMSG_LEN(len: size_t): size_t;
|
||||
begin
|
||||
Result:=CMSG_ALIGN(SizeOf(cmsghdr))+len;
|
||||
end;
|
||||
|
||||
function CMSG_DATA(cmsg: Pointer): PByte;
|
||||
begin
|
||||
Result:=PByte(Cardinal(cmsg) + SizeOf(Pcmsghdr));
|
||||
end;
|
||||
|
||||
33
rtl/linux/unixsocketsh.inc
Normal file
33
rtl/linux/unixsocketsh.inc
Normal file
@ -0,0 +1,33 @@
|
||||
const
|
||||
clib = 'c';
|
||||
|
||||
type
|
||||
Pmsghdr = ^msghdr;
|
||||
msghdr = record
|
||||
msg_name : pointer;
|
||||
msg_namelen : socklen_t;
|
||||
msg_iov : piovec;
|
||||
msg_iovlen : size_t;
|
||||
msg_control : pointer;
|
||||
msg_controllen : socklen_t;
|
||||
msg_flags : cInt;
|
||||
end;
|
||||
|
||||
Pcmsghdr = ^cmsghdr;
|
||||
cmsghdr = record
|
||||
cmsg_len : socklen_t;
|
||||
cmsg_level : cInt;
|
||||
cmsg_type : cInt;
|
||||
end;
|
||||
|
||||
function sendmsg(__fd: cInt; __message: pmsghdr; __flags: cInt): ssize_t; cdecl; external clib name 'sendmsg';
|
||||
function recvmsg(__fd: cInt; __message: pmsghdr; __flags: cInt): ssize_t; cdecl; external clib name 'recvmsg';
|
||||
|
||||
function CMSG_FIRSTHDR(mhdr: Pmsghdr): Pcmsghdr;
|
||||
function CMSG_NXTHDR(mhdr: Pmsghdr; cmsg: Pcmsghdr): Pcmsghdr;
|
||||
function CMSG_ALIGN(len: size_t): size_t;
|
||||
function CMSG_SPACE(len: size_t): size_t;
|
||||
function CMSG_LEN(len: size_t): size_t;
|
||||
function CMSG_DATA(cmsg : pcmsghdr) : Pbyte;
|
||||
|
||||
|
||||
19
rtl/unix/unixsockets.pas
Normal file
19
rtl/unix/unixsockets.pas
Normal file
@ -0,0 +1,19 @@
|
||||
unit unixsockets;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
{$packrecords C}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
cTypes, BaseUnix;
|
||||
|
||||
{$unixsocketsh.inc}
|
||||
|
||||
implementation
|
||||
|
||||
{$unixsockets.inc}
|
||||
|
||||
end.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user