[fpc-devel]adding the poll() call

Johannes Berg johannes at sipsolutions.de
Sun Nov 9 23:28:24 CET 2003


Hi,

This is probably not a very nice patch to add fpPoll(), but I really do
not know anything about the layout of all the files.

Basic testing lets me assume that it works (I see no reason why it
should work in basic tests but fail under some other conditions).

Obviously, it will have to be added to other platforms as well (the poll
syscall number seems to be present in some already), but I know nothing
and don't have any other machine at hand.

Index: unix/bunxh.inc
===================================================================
RCS file: /FPC/CVS/fpc/rtl/unix/bunxh.inc,v
retrieving revision 1.10
diff -u -r1.10 bunxh.inc
--- unix/bunxh.inc	27 Sep 2003 13:49:41 -0000	1.10
+++ unix/bunxh.inc	9 Nov 2003 22:23:43 -0000
@@ -98,6 +98,7 @@
     Function  FPSelect     (N:cint;readfds,writefds,exceptfds:pfdSet;TimeOut:PTimeVal):cint;
     Function  FpIOCtl      (Handle:cint;Ndx: culong;Data: Pointer):cint;
     Function  FpNanoSleep  (req : ptimespec;rem : ptimespec):cint;
+    Function  FpPoll       (const ufds: PPollFD; const nfds: Cardinal; const timeout: LongInt): LongInt;
 
     Function  FpGetEnv     (name : pChar): pChar;
     Function  FpGetEnv     (name : String): pChar;
Index: linux/ptypes.inc
===================================================================
RCS file: /FPC/CVS/fpc/rtl/linux/ptypes.inc,v
retrieving revision 1.5
diff -u -r1.5 ptypes.inc
--- linux/ptypes.inc	27 Sep 2003 13:45:58 -0000	1.5
+++ linux/ptypes.inc	9 Nov 2003 22:23:44 -0000
@@ -120,6 +120,14 @@
   ptimespec   = ^timespec;
   TTimeSpec   = timespec;
 
+  pollfd      = packed record
+                  fd: LongInt;      (* file descriptor *)
+                  events,           (* requested events *)
+                  revents : word;   (* returned events *)
+                end;
+  TPollFD     = pollfd;
+  PPollFD     = ^TPollFD;
+
 CONST
    { System limits, POSIX value in parentheses, used for buffer and stack allocation }
    { took idefix' values}
Index: linux/bunxfunc.inc
===================================================================
RCS file: /FPC/CVS/fpc/rtl/linux/bunxfunc.inc,v
retrieving revision 1.5
diff -u -r1.5 bunxfunc.inc
--- linux/bunxfunc.inc	27 Sep 2003 13:45:58 -0000	1.5
+++ linux/bunxfunc.inc	9 Nov 2003 22:23:44 -0000
@@ -431,6 +431,11 @@
   fpSelect:=do_syscall(syscall_nr_select,longint(@selectarray));
 end;
 
+function fpPoll(const ufds: PPollFD; const nfds: Cardinal; const timeout: LongInt): LongInt;
+begin
+  fpPoll := do_syscall(syscall_nr_poll, longint(ufds), longint(nfds), longint(timeout));
+end;
+
 {
  $Log: bunxfunc.inc,v $
  Revision 1.5  2003/09/27 13:45:58  peter
Index: linux/bunxtype.inc
===================================================================
RCS file: /FPC/CVS/fpc/rtl/linux/bunxtype.inc,v
retrieving revision 1.3
diff -u -r1.3 bunxtype.inc
--- linux/bunxtype.inc	14 Sep 2003 20:15:01 -0000	1.3
+++ linux/bunxtype.inc	9 Nov 2003 22:23:44 -0000
@@ -241,6 +241,20 @@
     WNOHANG   =          1;     { don't block waiting               }
     WUNTRACED =          2;     { report status of stopped children }
 
+    { poll() constants }
+    POLLIN      =    $0001;
+    POLLPRI     =    $0002;
+    POLLOUT     =    $0004;
+    POLLERR     =    $0008;
+    POLLHUP     =    $0010;
+    POLLNVAL    =    $0020;
+    POLLRDNORM  =    $0040;
+    POLLRDBAND  =    $0080;
+    POLLWRNORM  =    $0100;
+    POLLWRBAND  =    $0200;
+    POLLMSG     =    $0400;
+
+
 
     {*************************************************************************}
     {                               SIGNALS                                   }


johannes
-- 
http://www.sipsolutions.de/
GnuPG key: http://www.sipsolutions.de/keys/JohannesBerg.asc
  Key-ID: 9AB78CA5 Johannes Berg <johannes at sipsolutions.de>
  Fingerprint = AD02 0176 4E29 C137 1DF6 08D2 FC44 CF86 9AB7 8CA5
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20031109/177dcbbb/attachment.sig>


More information about the fpc-devel mailing list