Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2003-11

adding the poll() call

9 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Johannes Berg

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 : 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 Fingerprint = AD02 0176 4E29 C137 1DF6 08D2 FC44 CF86 9AB7 8CA5

Reply by email

Unknown author
to Johannes Berg
Johannes Berg wrote
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.

poll() is not part of the POSIX interface, so I'm not sure we'll include this. The idea is that the interface is POSIX compliant, to ease porting. Non-POSIX calls must therefore be moved to other (platform-specific) units.

Marco, what do you think ?

Michael.

Reply by email

Marco van de Voort
to Unknown author
Show quoted text 8 lines
On Sun, 9 Nov 2003, Johannes Berg wrote: > 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. poll() is not part of the POSIX interface, so I'm not sure we'll include this. The idea is that the interface is POSIX compliant, to ease porting. Non-POSIX calls must therefore be moved to other (platform-specific) units.

unit Unix is for common unix calls that are not POSIX. I'm still wondering if I should prefix unit unix too. (e.g. to avoid name clashes with similar units like Kylix' libc)

Marco, what do you think ?

It could be in unit Unix. The BSD's have it, and Solaris (and probably most commercial SysV derivates) too.

I also could move ioperm and iopl to unit x86, but that means unit x86 would get platform dependant. And clone goes to systemdependant too as soon as it isn't used anymore for threads.

P.s. I'm currently cleaning up unit unix. I eliminated linuxerror, introducing more typing typing etc. I also committed the 1.0.x linux unit as "oldlinux", for linux/i386 only with everything (*.inc's) inlined.

Reply by email

Johannes Berg
to Unknown author: poll() is not part of the POSIX interface, so I'm not sure we'll include this. The idea…
poll() is not part of the POSIX interface, so I'm not sure we'll include this.

What do you define as POSIX interface?
http://www.opengroup.org/onlinepubs/007904975/functions/poll.html (IEEE Std. 1003.1 Issue 6) http://www.opengroup.org/onlinepubs/007908799/xsh/poll.h.html (SUSv2)

johannes

http://www.sipsolutions.de/ GnuPG key: http://www.sipsolutions.de/keys/JohannesBerg.asc Key-ID: 9AB78CA5 Johannes Berg Fingerprint = AD02 0176 4E29 C137 1DF6 08D2 FC44 CF86 9AB7 8CA5

Reply by email

Marco van de Voort
to Johannes Berg: What do you define as POSIX interface? http://www.opengroup.org/onlinepubs/007904975/funct…

-- Start of PGP signed section.

Show quoted text 6 lines
On Sat, 2003-11-15 at 12:33, wrote: > poll() is not part of the POSIX interface, so I'm not sure we'll include this. What do you define as POSIX interface? http://www.opengroup.org/onlinepubs/007904975/functions/poll.html (IEEE Std. 1003.1 Issue 6) http://www.opengroup.org/onlinepubs/007908799/xsh/poll.h.html (SUSv2)

I usually use a 1989 spec, but add functions of later ones if they are commonly used or useful.

Michael states a bit wrong when he says baseunix is a posix unit.

I just wanted to make a shift between common, portable and other calls.

So baseunix gets the really standard ones, Unix the ones the avg free unix has, and the rest moves to OS specific units.

e.g. in the FreeBSD case

baseunix more portable
|
unix |
| |
bsd V
|
freebsd OS specific

I used the POSIX spec as a first indicator for what should be in baseunix, but I don't want to follow that 100%.

Baseunix is meant for easy porting of basic apps. (which is why e.g. nanosleep is there) If I add all POSIX 2003 funcs and extensions, people with older commercial OSes have to put more work in porting baseunix, then the old 1.0.x linux unit, which was horribly linux specific.

Reply by email

Michael Van Canneyt
to Uberto Barbini (Gamasoft: did anyone ever consider to create a FPC plugin for Eclipse? I'm using Eclipse at work…
Uberto Barbini wrote
Hi, did anyone ever consider to create a FPC plugin for Eclipse?

Not that I am aware of.

I'm using Eclipse at work and it's by far the best ide I ever seen, it's also very easy to enhance it and language neutral, although a such plugin is not really trivial.

It's also written very much in Java and - at least in my experience - dog slow. But don't let that stop you.

Michael.

Reply by email

Michael Van Canneyt
to Johannes Berg: What do you define as POSIX interface? http://www.opengroup.org/onlinepubs/007904975/funct…
Johannes Berg wrote
On Sat, 2003-11-15 at 12:33, wrote: > poll() is not part of the POSIX interface, so I'm not sure we'll include this. What do you define as POSIX interface?

Good question.

I'll check my manual for the version. I checked it before I sent my previous post, and it definitely wasn't there.

Michael.

Reply by email