forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

newlib pipe.c implementation [non]-blocking read() PATCH

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
anhanguera



Joined: 26 Aug 2004
Posts: 31

PostPosted: Thu May 31, 2007 10:13 pm    Post subject: newlib pipe.c implementation [non]-blocking read() PATCH Reply with quote

hi,

- in __psp_pipe_read (...) it is looking for how many bytes already in the pipe with __psp_pipe_peekmsgsize(...). and if there is no data already in the pipe, returns '-1'. this is correct for 'non-blocking read', for 'blocking read' it should wait until some data cames in to the pipe.

- in __psp_pipe_nonblocking_read (...) it sets the errno 'EBADF' if pipe fd is OK, but there is no data available at the moment. it should set errno to 'EAGAIN' if the pipe fd is OK, but there no data avail.

here is the patch for these;

Code:
Index: patches/newlib-1.15.0-PSP.patch
===================================================================
--- patches/newlib-1.15.0-PSP.patch     (revision 2235)
+++ patches/newlib-1.15.0-PSP.patch     (working copy)
@@ -7420,7 +7420,7 @@
 diff -burN orig.newlib-1.15.0/newlib/libc/sys/psp/pipe.c newlib-1.15.0/newlib/libc/sys/psp/pipe.c
 --- orig.newlib-1.15.0/newlib/libc/sys/psp/pipe.c      1969-12-31 20:00:00.000000000 -0400
 +++ newlib-1.15.0/newlib/libc/sys/psp/pipe.c   2007-05-29 15:02:51.000000000 -0300
-@@ -0,0 +1,276 @@
+@@ -0,0 +1,285 @@
 +/*
 + * PSP Software Development Kit - http://www.pspdev.org
 + * -----------------------------------------------------------------------
@@ -7551,6 +7551,10 @@
 +                      len = size;
 +              }
 +      }
++      else if (size == 0) {
++              errno = EAGAIN;
++              return -1;
++      }
 +      else {
 +              errno = EBADF;
 +              return -1;
@@ -7595,6 +7599,10 @@
 +
 +      sceuid = __psp_descriptormap[fd]->sce_descriptor;
 +
++#if 0
++      /* we should block until there is some data (or maybe for enough data),
++       * peeking the msg size should be only for nonblocking reads
++       */
 +      size = __psp_pipe_peekmsgsize(fd);
 +      if (size > 0) {
 +              if (size < len) {
@@ -7605,6 +7613,7 @@
 +              errno = EBADF;
 +              return -1;
 +      }
++#endif
 +
 +      /**
 +      * Receive a message from a pipe
@@ -7700,7 +7709,7 @@
 diff -burN orig.newlib-1.15.0/newlib/libc/sys/psp/pipe.c.orig newlib-1.15.0/newlib/libc/sys/psp/pipe.c.orig
 --- orig.newlib-1.15.0/newlib/libc/sys/psp/pipe.c.orig 1969-12-31 20:00:00.000000000 -0400
 +++ newlib-1.15.0/newlib/libc/sys/psp/pipe.c.orig      2007-05-29 15:00:50.000000000 -0300
-@@ -0,0 +1,271 @@
+@@ -0,0 +1,280 @@
 +/*
 + * PSP Software Development Kit - http://www.pspdev.org
 + * -----------------------------------------------------------------------
@@ -7831,6 +7840,10 @@
 +                      len = size;
 +              }
 +      }
++      else if (size == 0) {
++              errno = EAGAIN;
++              return -1;
++      }
 +      else {
 +              errno = EBADF;
 +              return -1;
@@ -7875,6 +7888,10 @@
 +
 +      sceuid = __psp_descriptormap[fd]->sce_descriptor;
 +
++#if 0
++      /* we should block until there is some data (or maybe for enough data),
++       * peeking the msg size should be only for nonblocking reads
++       */
 +      size = __psp_pipe_peekmsgsize(fd);
 +      if (size > 0) {
 +              if (size < len) {
@@ -7885,6 +7902,7 @@
 +              errno = EBADF;
 +              return -1;
 +      }
++#endif
 +
 +      /**
 +      * Receive a message from a pipe

cheers,
anhanguera.
Back to top
View user's profile Send private message
ooPo
Site Admin


Joined: 17 Jan 2004
Posts: 2032
Location: Canada

PostPosted: Fri Jun 01, 2007 4:36 am    Post subject: Reply with quote

This has been updated in the repository.
Back to top
View user's profile Send private message Visit poster's website
anhanguera



Joined: 26 Aug 2004
Posts: 31

PostPosted: Fri Jun 01, 2007 6:47 am    Post subject: Reply with quote

thanks ;)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group