This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Bug libfortran/26423][4.1/4.2 Regression] Error on binary I/O for large array


The attached patch fixes this regression. It is a revert of changes made to unix.c in patch for PR25949. Bootstrapped, regtested, NIST tested, tested with the test case attached.

OK for 4.2?

Mark can you get this into 4.1 before release?

Regards,

Jerry

2006-02-24 Jerry DeLisle <jvdelisle@gcc.gnu.org>

	PR libgfortran/26423
	* io/unix.c (fd_seek): Revert change from 25949.
	(fd_read): Same.
	(fd_write): Same.
Index: io/unix.c
===================================================================
*** io/unix.c	(revision 111412)
--- io/unix.c	(working copy)
*************** fd_sfree (unix_stream * s)
*** 562,570 ****
  static try
  fd_seek (unix_stream * s, gfc_offset offset)
  {
!   s->logical_offset = offset;
  
!   return SUCCESS;
  }
  
  
--- 562,576 ----
  static try
  fd_seek (unix_stream * s, gfc_offset offset)
  {
!   if (s->physical_offset == offset) /* Are we lucky and avoid syscall?  */
!     {
!       s->logical_offset = offset;
!       return SUCCESS;
!     }
  
!   s->physical_offset = s->logical_offset = offset;
! 
!   return (lseek (s->fd, offset, SEEK_SET) < 0) ? FAILURE : SUCCESS;
  }
  
  
*************** fd_read (unix_stream * s, void * buf, si
*** 666,673 ****
        return errno;
      }
  
!   if (is_seekable ((stream *) s) && s->physical_offset != s->logical_offset 
!       && lseek (s->fd, s->logical_offset, SEEK_SET) < 0)
      {
        *nbytes = 0;
        return errno;
--- 672,678 ----
        return errno;
      }
  
!   if (is_seekable ((stream *) s) && fd_seek (s, s->logical_offset) == FAILURE)
      {
        *nbytes = 0;
        return errno;
*************** fd_write (unix_stream * s, const void * 
*** 715,722 ****
        return errno;
      }
  
!   if (is_seekable ((stream *) s) && s->physical_offset != s->logical_offset
!       && lseek (s->fd, s->logical_offset, SEEK_SET) < 0)
      {
        *nbytes = 0;
        return errno;
--- 720,726 ----
        return errno;
      }
  
!   if (is_seekable ((stream *) s) && fd_seek (s, s->logical_offset) == FAILURE)
      {
        *nbytes = 0;
        return errno;
!{ dg-do run }
! PR26423 Large file I/O error related to buffering
! Test case derived from case by Dale Ranta.
! Submitted  by Jerry DeLisle  <jvdelisle@gcc.gnu.org> 
      integer :: a(3000) , b(2048)
      a=3
      b=5
      a(1) = 1
      a(3000)=1234
      write(2) a
      b(1) = 2
      b(2048) = 5678
      write(2) b
      rewind 2
      read(2) a
      read(2) b
      if (a(1).ne.1) call abort()
      if (a(2).ne.3) call abort()
      if (b(1).ne.2) call abort()
      if (b(2).ne.5) call abort()
      if (a(3000).ne.1234) call abort()
      if (b(2048).ne.5678) call abort()
      end

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]