4 {$define tv_sec := sec}
\r
5 {$define tv_usec := usec}
\r
6 function dup(const original:integer):integer;inline;
\r
8 linux.dup(original,result);
\r
10 {$define gettimeofdaysec := gettimeofday}
\r
14 function ntohs(invalue:word):word;inline;
\r
16 invaluebytes : array[0..1] of byte absolute invalue;
\r
17 resultbytes : array[0..1] of byte absolute result;
\r
19 {$ifdef endian_little}
\r
20 resultbytes[0] := invaluebytes[1];
\r
21 resultbytes[1] := invaluebytes[0];
\r
26 {$define need_v6constants}
\r
29 {$define sigprocmask := fpsigprocmask}
\r
30 {$define sigaction := fpsigaction}
\r
31 {$define fdclose := fpclose}
\r
32 {$define fcntl := fpfcntl}
\r
33 {$define fdwrite := fpwrite}
\r
34 {$define fdread := fpread}
\r
35 {$define fdopen := fpopen}
\r
36 {$define select := fpselect}
\r
37 {$define linuxerror := fpgeterrno}
\r
38 {$define fork := fpfork}
\r
39 {$define getpid := fpgetpid}
\r
40 {$define getenv := fpgetenv}
\r
41 {$define chmod := fpchmod}
\r
42 {$define dup2 := fpdup2}
\r
44 {$define flock := fpflock}
\r
46 {$if FPC_FULLVERSION >= 30200}
\r
47 procedure Execl(Todo:rawbytestring);inline;
\r
49 procedure Execl(Todo:string);inline;
\r
54 p := unixutil.StringToPPChar(Todo,0);
\r
55 if (p=nil) or (p^=nil) then exit;
\r
58 function SendTo(Sock: LongInt; const Buf;BufLen: LongInt;Flags: LongInt;var Addr;AddrLen: LongInt):LongInt;
\r
60 result := fpsendto(sock,@buf,buflen,flags,@addr,addrlen);
\r
62 function RecvFrom(Sock: LongInt;var Buf;Buflen: LongInt;Flags: LongInt;var Addr;var addrlen: Longint):LongInt;
\r
64 result := fprecvfrom(sock,@buf,buflen,flags,@addr,@addrlen);
\r
66 {$define socket := fpsocket}
\r
67 function Bind(Sock: LongInt;const Addr;AddrLen: LongInt):Boolean;
\r
69 result := fpbind(sock,@addr,addrlen) = 0;
\r
71 function SetSocketOptions(Sock: LongInt;Level: LongInt;OptName: LongInt;const OptVal;optlen: LongInt):LongInt;
\r
73 result := fpsetsockopt(sock,level,optname,@optval,optlen);
\r
75 function Connect(Sock: LongInt;const Addr;Addrlen: LongInt):Boolean;
\r
77 result := fpconnect(sock,@addr,addrlen) >= 0;
\r
79 function listen(Sock: LongInt;MaxConnect: LongInt):Boolean;
\r
81 result := fplisten(sock,maxconnect) = 0;
\r
83 function GetPeerName(Sock: LongInt; var Addr;var Addrlen: LongInt):LongInt;
\r
85 result := fpgetpeername(sock,@addr,@addrlen);
\r
87 function GetSocketName(Sock: LongInt; var Addr;var Addrlen: LongInt):LongInt;
\r
89 result := fpgetsockname(sock,@addr,@addrlen);
\r
91 function Accept(Sock: LongInt; var Addr; var Addrlen: LongInt):LongInt;
\r
93 result := fpaccept(sock,@addr,@addrlen);
\r
101 {$define need_v6constants}
\r
107 function ntohs(invalue:word):word;inline;
\r
109 invaluebytes : array[0..1] of byte absolute invalue;
\r
110 resultbytes : array[0..1] of byte absolute result;
\r
112 {$ifdef endian_little}
\r
113 resultbytes[0] := invaluebytes[1];
\r
114 resultbytes[1] := invaluebytes[0];
\r
119 {$define need_v6constants}
\r
121 procedure gettimeofday(var tv:ttimeval);inline;
\r
123 fpgettimeofday(@tv,nil);
\r
125 function gettimeofdaysec : longint;
\r
130 result := tv.tv_sec;
\r
133 //a function is used here rather than a define to prevent issues with tlasio.dup
\r
134 function dup(const original:integer):integer;inline;
\r
136 result := fpdup(original);
\r
138 function octal(invalue:longint):longint;
\r
145 while invalue <> 0 do begin
\r
146 a := invalue mod 10;
\r
147 result := result + (a shl (i*3));
\r
149 invalue := invalue div 10;
\r
154 sys_eintr=esyseintr;
\r
157 {$ifdef need_v6constants}
\r
159 //the below values are only known correct on linux, I don't support
\r
160 //1.0.x on any other unix platform atm anyway --plugwash
\r
167 //freepascal doesn't seem to define IPV6_V6ONLY on freebsd, the definition
\r
168 //here is taken from the include files of a freebsd 8 system
\r