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         procedure Execl(Todo:string);inline;
\r 
  50           p := unixutil.StringToPPChar(Todo,1);
\r 
  51           if (p=nil) or (p^=nil) then exit;
\r 
  54         function SendTo(Sock: LongInt; const Buf;BufLen: LongInt;Flags: LongInt;var Addr;AddrLen: LongInt):LongInt;
\r 
  56           result := fpsendto(sock,@buf,buflen,flags,@addr,addrlen);
\r 
  58         function RecvFrom(Sock: LongInt;var Buf;Buflen: LongInt;Flags: LongInt;var Addr;var addrlen: Longint):LongInt;
\r 
  60           result := fprecvfrom(sock,@buf,buflen,flags,@addr,@addrlen);
\r 
  62         {$define socket := fpsocket}
\r 
  63         function Bind(Sock: LongInt;const Addr;AddrLen: LongInt):Boolean;
\r 
  65           result := fpbind(sock,@addr,addrlen) = 0;
\r 
  67         function SetSocketOptions(Sock: LongInt;Level: LongInt;OptName: LongInt;const OptVal;optlen: LongInt):LongInt;
\r 
  69           result := fpsetsockopt(sock,level,optname,@optval,optlen);
\r 
  71         function Connect(Sock: LongInt;const Addr;Addrlen: LongInt):Boolean;
\r 
  73           result := fpconnect(sock,@addr,addrlen) >= 0;
\r 
  75         function listen(Sock: LongInt;MaxConnect: LongInt):Boolean;
\r 
  77           result := fplisten(sock,maxconnect) = 0;
\r 
  79         function GetPeerName(Sock: LongInt; var Addr;var Addrlen: LongInt):LongInt;
\r 
  81           result := fpgetpeername(sock,@addr,@addrlen);
\r 
  83         function GetSocketName(Sock: LongInt; var Addr;var Addrlen: LongInt):LongInt;
\r 
  85           result := fpgetsockname(sock,@addr,@addrlen);
\r 
  87         function Accept(Sock: LongInt; var Addr; var Addrlen: LongInt):LongInt;
\r 
  89           result := fpaccept(sock,@addr,@addrlen);
\r 
  97       {$define need_v6constants}
\r 
 103       function ntohs(invalue:word):word;inline;
\r 
 105         invaluebytes : array[0..1] of byte absolute invalue;
\r 
 106         resultbytes : array[0..1] of byte absolute result;
\r 
 108         {$ifdef endian_little}
\r 
 109           resultbytes[0] := invaluebytes[1];
\r 
 110           resultbytes[1] := invaluebytes[0];
\r 
 115       {$define need_v6constants}
\r 
 117     procedure gettimeofday(var tv:ttimeval);inline;
\r 
 119       fpgettimeofday(@tv,nil);    
\r 
 121     function gettimeofdaysec : longint;
\r 
 126       result := tv.tv_sec;
\r 
 129     //a function is used here rather than a define to prevent issues with tlasio.dup
\r 
 130     function dup(const original:integer):integer;inline;
\r 
 132       result := fpdup(original);
\r 
 134     function octal(invalue:longint):longint;
\r 
 141       while invalue <> 0 do begin
\r 
 142         a := invalue mod 10;
\r 
 143         result := result + (a shl (i*3));
\r 
 145         invalue := invalue div 10;
\r 
 150       sys_eintr=esyseintr;
\r 
 153   {$ifdef need_v6constants}
\r 
 155       //the below values are only known correct on linux, I don't support 
\r 
 156       //1.0.x on any other unix platform atm anyway --plugwash
\r 
 163     //freepascal doesn't seem to define IPV6_V6ONLY on freebsd, the definition
\r 
 164     //here is taken from the include files of a freebsd 8 system
\r