mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-02-25 04:55:29 +08:00
re PR libfortran/43551 (Buffered direct I/O reads wrong record)
2010-03-29 Tobias Burnus <burnus@net-b.de> PR fortran/43551 * io/unix.c (buf_write): Set physical_offset after lseek. 2010-03-29 Tobias Burnus <burnus@net-b.de> PR fortran/43551 * gfortran.dg/direct_io_12.f90: New test. From-SVN: r157792
This commit is contained in:
parent
090f6087fe
commit
10fa280a98
@ -1,3 +1,8 @@
|
|||||||
|
2010-03-29 Tobias Burnus <burnus@net-b.de>
|
||||||
|
|
||||||
|
PR fortran/43551
|
||||||
|
* gfortran.dg/direct_io_12.f90: New test.
|
||||||
|
|
||||||
2010-03-28 Jan Hubicka <jh@suse.cz>
|
2010-03-28 Jan Hubicka <jh@suse.cz>
|
||||||
|
|
||||||
PR tree-optimization/43505
|
PR tree-optimization/43505
|
||||||
|
33
gcc/testsuite/gfortran.dg/direct_io_12.f90
Normal file
33
gcc/testsuite/gfortran.dg/direct_io_12.f90
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
! { dg-do run }
|
||||||
|
!
|
||||||
|
! PR fortran/43551
|
||||||
|
!
|
||||||
|
! Writes a 672000 byte file with buffering. The writing failed because
|
||||||
|
! of a missing lseek.
|
||||||
|
|
||||||
|
implicit none
|
||||||
|
integer, parameter :: size = 2800 ! << needs to be large enough
|
||||||
|
real(8) :: vec1(size,30), dummy(size)
|
||||||
|
integer i
|
||||||
|
|
||||||
|
CALL RANDOM_NUMBER(vec1)
|
||||||
|
|
||||||
|
open(99, file='test.dat', form='unformatted', access='direct', recl=size*8)
|
||||||
|
do i = 1, 10
|
||||||
|
write(99,rec=i) vec1(:,i)
|
||||||
|
write(99,rec=i+10) vec1(:,i+10)
|
||||||
|
write(99,rec=i+20) vec1(:,i+20) ! << rec = 30 was written to rec = 21
|
||||||
|
end do
|
||||||
|
|
||||||
|
do i = 1, 10
|
||||||
|
read(99,rec=i) dummy
|
||||||
|
if (any (dummy /= vec1(:,i))) call abort()
|
||||||
|
read(99,rec=i+10) dummy
|
||||||
|
if (any (dummy /= vec1(:,i+10))) call abort()
|
||||||
|
read(99,rec=i+20) dummy
|
||||||
|
if (any (dummy /= vec1(:,i+20))) call abort() ! << aborted here for rec = 21
|
||||||
|
end do
|
||||||
|
|
||||||
|
close(99, status='delete')
|
||||||
|
end
|
||||||
|
|
@ -1,3 +1,8 @@
|
|||||||
|
2010-03-29 Tobias Burnus <burnus@net-b.de>
|
||||||
|
|
||||||
|
PR fortran/43551
|
||||||
|
* io/unix.c (buf_write): Set physical_offset after lseek.
|
||||||
|
|
||||||
2010-03-25 Jerry DeLisle <jvdelisle@gcc.gnu.org>
|
2010-03-25 Jerry DeLisle <jvdelisle@gcc.gnu.org>
|
||||||
|
|
||||||
PR libfortran/43517
|
PR libfortran/43517
|
||||||
|
@ -496,13 +496,17 @@ buf_write (unix_stream * s, const void * buf, ssize_t nbyte)
|
|||||||
s->ndirty += nbyte;
|
s->ndirty += nbyte;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (s->file_length != -1 && s->physical_offset != s->logical_offset
|
if (s->file_length != -1 && s->physical_offset != s->logical_offset)
|
||||||
&& lseek (s->fd, s->logical_offset, SEEK_SET) < 0)
|
{
|
||||||
return -1;
|
if (lseek (s->fd, s->logical_offset, SEEK_SET) < 0)
|
||||||
nbyte = raw_write (s, buf, nbyte);
|
return -1;
|
||||||
s->physical_offset += nbyte;
|
s->physical_offset = s->logical_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nbyte = raw_write (s, buf, nbyte);
|
||||||
|
s->physical_offset += nbyte;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
s->logical_offset += nbyte;
|
s->logical_offset += nbyte;
|
||||||
/* Don't increment file_length if the file is non-seekable. */
|
/* Don't increment file_length if the file is non-seekable. */
|
||||||
|
Loading…
Reference in New Issue
Block a user