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         //beware: this is needed because FPC_FULLVERSION >= 30200 breaks delphi 6 even inside an ifdef it shouldn't process
\r 
  49             {$ifndef ver3_0}{$ifndef ver3_1}{$define fpc_3_2_or_later}{$endif}{$endif}
\r 
  51           {$ifdef ver4}{$define fpc_3_2_or_later}{$endif}
\r 
  53         {$ifdef fpc_3_2_or_later}
\r 
  54           procedure Execl(Todo:rawbytestring);inline;
\r 
  56           procedure Execl(Todo:string);inline;
\r 
  61           p := unixutil.StringToPPChar(Todo,0);
\r 
  62           if (p=nil) or (p^=nil) then exit;
\r 
  65         function SendTo(Sock: LongInt; const Buf;BufLen: LongInt;Flags: LongInt;var Addr;AddrLen: LongInt):LongInt;
\r 
  67           result := fpsendto(sock,@buf,buflen,flags,@addr,addrlen);
\r 
  69         function RecvFrom(Sock: LongInt;var Buf;Buflen: LongInt;Flags: LongInt;var Addr;var addrlen: Longint):LongInt;
\r 
  71           result := fprecvfrom(sock,@buf,buflen,flags,@addr,@addrlen);
\r 
  73         {$define socket := fpsocket}
\r 
  74         function Bind(Sock: LongInt;const Addr;AddrLen: LongInt):Boolean;
\r 
  76           result := fpbind(sock,@addr,addrlen) = 0;
\r 
  78         function SetSocketOptions(Sock: LongInt;Level: LongInt;OptName: LongInt;const OptVal;optlen: LongInt):LongInt;
\r 
  80           result := fpsetsockopt(sock,level,optname,@optval,optlen);
\r 
  82         function Connect(Sock: LongInt;const Addr;Addrlen: LongInt):Boolean;
\r 
  84           result := fpconnect(sock,@addr,addrlen) >= 0;
\r 
  86         function listen(Sock: LongInt;MaxConnect: LongInt):Boolean;
\r 
  88           result := fplisten(sock,maxconnect) = 0;
\r 
  90         function GetPeerName(Sock: LongInt; var Addr;var Addrlen: LongInt):LongInt;
\r 
  92           result := fpgetpeername(sock,@addr,@addrlen);
\r 
  94         function GetSocketName(Sock: LongInt; var Addr;var Addrlen: LongInt):LongInt;
\r 
  96           result := fpgetsockname(sock,@addr,@addrlen);
\r 
  98         function Accept(Sock: LongInt; var Addr; var Addrlen: LongInt):LongInt;
\r 
 100           result := fpaccept(sock,@addr,@addrlen);
\r 
 108       {$define need_v6constants}
\r 
 114       function ntohs(invalue:word):word;inline;
\r 
 116         invaluebytes : array[0..1] of byte absolute invalue;
\r 
 117         resultbytes : array[0..1] of byte absolute result;
\r 
 119         {$ifdef endian_little}
\r 
 120           resultbytes[0] := invaluebytes[1];
\r 
 121           resultbytes[1] := invaluebytes[0];
\r 
 126       {$define need_v6constants}
\r 
 128     function gettimeofday(var tv:ttimeval):integer; inline;
\r 
 130       result := fpgettimeofday(@tv,nil);
\r 
 132     function gettimeofdaysec : longint;
\r 
 137       result := tv.tv_sec;
\r 
 140     //a function is used here rather than a define to prevent issues with tlasio.dup
\r 
 141     function dup(const original:integer):integer;inline;
\r 
 143       result := fpdup(original);
\r 
 145     function octal(invalue:longint):longint;
\r 
 152       while invalue <> 0 do begin
\r 
 153         a := invalue mod 10;
\r 
 154         result := result + (a shl (i*3));
\r 
 156         invalue := invalue div 10;
\r 
 161       sys_eintr=esyseintr;
\r 
 164   {$ifdef need_v6constants}
\r 
 166       //the below values are only known correct on linux, I don't support 
\r 
 167       //1.0.x on any other unix platform atm anyway --plugwash
\r 
 174     //freepascal doesn't seem to define IPV6_V6ONLY on freebsd, the definition
\r 
 175     //here is taken from the include files of a freebsd 8 system
\r