Changes made in GCCSDK for CVS

Peter Naulls peter at chocky.org
Mon Oct 14 03:08:09 PDT 2002


In message <3DAA82E4.9000702 at arm.com>
          Alex Waugh <Alex.Waugh at arm.com> wrote:

> > I have a more comprehensive fix to this, but it doesn't seem to have
> > made it into CVS. Nick - can you check back?
> 
> I'm not sure what your fix is, but yesterday purely by coincidence I 
> found a bug in __riscosify's handling of /tmp and /pipe. I've been 
> reworking the whole of __riscosify to try and fix some bugs; I'll post 
> more details in a few days.

I'm really not sure what happened to the post, and as such, I can't tell
you exactly why the changes are needed.  All I can say on the matter is
that it's required for 'links' to work correctly, and I've had no other
problems with handling of pipes.

I do recall there was some odd behaviour - such as you can see below
where it would unhelpfully turn off the S_PIPE flag, thereby causing
problems.


Patch follows.


Index: unixlib/source/unix/dev.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/unixlib/source/unix/dev.c,v
retrieving revision 1.2.2.9
diff -u -r1.2.2.9 dev.c
--- unixlib/source/unix/dev.c	18 Aug 2002 19:57:19 -0000	1.2.2.9
+++ unixlib/source/unix/dev.c	14 Oct 2002 10:03:03 -0000
@@ -505,11 +505,6 @@
 int
 __piperead (struct __unixlib_fd *file_desc, void *data, int nbyte)
 {
-  if (file_desc->fflag & O_PIPE)
-    {
-      file_desc->fflag &= ~O_PIPE;
-      __fslseek (file_desc, 0, 0);
-    }
   return __fsread (file_desc, data, nbyte);
 }
 
@@ -518,9 +513,6 @@
 {
   int handle, regs[3];
 
-  if (file_desc->fflag & O_PIPE)
-    return __fswrite (file_desc, data, nbyte);
-
   handle = (int) file_desc->handle;
   /* Read current file position.  */
   if (! __os_args (0, handle, 0, regs))
@@ -564,40 +556,28 @@
 __pipeselect (struct __unixlib_fd *file_desc, int fd,
 		__fd_set *read, __fd_set *write, __fd_set *except)
 {
-  /* Return ready to write, no execptional conditions.  Ready to read is a
+  /* Return ready to write, no exceptional conditions.  Ready to read is a
      little more tricky.  Bascially, work out if there is any data ready.
      Start by assuming there is nothing to read.  */
   int to_read = 0;
+
   if (read)
     {
-      if (file_desc->fflag & O_PIPE)
-	{
-	  /* Not read anything yet.  */
-	  long where = __fslseek (file_desc, 0, SEEK_CUR);
-	  /* There is data to read unless file position is zero.  */
-	  if (where != 0 && where != -1)
-	    to_read = 1;
-	}
-	else
-	{
-	  /* Have already read something.  */
-	  int regs[3];
-	  int pos;
-	  /* Read current file position.  */
-	  if (! __os_args (0, (int)file_desc->handle, 0, regs))
-	    {
-	      pos = regs[2];
-	      /* Read extent.  */
-	      if (! __os_args (2, (int)file_desc->handle, 0, regs))
+	int regs[3];
+	int pos;
+	/* Read current file position.  */
+	if (! __os_args (0, (int)file_desc->handle, 0, regs))
+	  {
+	    pos = regs[2];
+	    /* Read extent.  */
+	    if (! __os_args (2, (int)file_desc->handle, 0, regs))
 		if (pos != regs[2])
 		  to_read = 1;
-	      /* If file pointer != extent then there is still data to
-		 read.  */
+	    /* If file pointer != extent then there is still data to read.  */
 	    }
-	}
-      if (to_read)
+      if (to_read) {
 	FD_SET(fd, read);
-      else
+      } else
 	FD_CLR (fd, read);
     }
 
@@ -606,8 +586,7 @@
   if (except)
     FD_CLR (fd, except);
 
-  /* This may not be correct, but it is consistent with Internet 5
-     select.  */
+  /* This may not be correct, but it is consistent with Internet 5 select.  */
   return to_read + (write ? 1 : 0);
 }
 #endif /* __FEATURE_PIPEDEV */


-- 
------------------------------------------------------------------------
 Peter Naulls - peter at chocky.org
 Homepage                     -  http://www.chocky.org/
 RISC OS C Programming        -  http://www.riscos.info/
 Unix Programs on RISC OS     -  http://www.chocky.org/unix/
------------------------------------------------------------------------
 



More information about the gcc mailing list