gcc/libgfortran
Janne Blomqvist 2412750e79 PR libgfortran/83649 Chunk large reads and writes
It turns out that Linux never reads or writes more than 2147479552
bytes in a single syscall. For writes this is not a problem as
libgfortran already contains a loop around write() to handle short
writes. But for reads we cannot do this, since then read will hang if
we have a short read when reading from the terminal.  Also, there are
reports that macOS fails I/O's larger than 2 GB.  Thus, to work around
these issues do large reads/writes in chunks.

The testcase from the PR

program largewr
  integer(kind=1) :: a(2_8**31+1)
  a = 0
  a(size(a, kind=8)) = 1
  open(10, file="largewr.dat", access="stream", form="unformatted")
  write (10) a
  close(10)
  a(size(a, kind=8)) = 2
  open(10, file="largewr.dat", access="stream", form="unformatted")
  read (10) a
  if (a(size(a, kind=8)) == 1) then
    print *, "All is well"
  else
    print *, "Oh no"
  end if
end program largewr

fails on trunk but works with the patch.

Regtested on x86_64-pc-linux-gnu, committed to trunk.

libgfortran/ChangeLog:

2018-01-02  Janne Blomqvist  <jb@gcc.gnu.org>

	PR libgfortran/83649
	* io/unix.c (MAX_CHUNK): New define.
	(raw_read): For reads larger than MAX_CHUNK, loop.
	(raw_write): Write no more than MAX_CHUNK bytes per iteration.

From-SVN: r256074
2018-01-02 15:25:10 +02:00
..
caf check.c (positive_check): Add new function checking constant for being greater then zero. 2017-03-05 12:35:47 +01:00
config Update copyright years. 2017-01-01 13:07:43 +01:00
generated re PR fortran/36313 ([F03] {MIN,MAX}{LOC,VAL} should accept character arguments) 2017-12-03 20:14:05 +00:00
ieee Update copyright years. 2017-01-01 13:07:43 +01:00
intrinsics Make shift argument to eoshift0 and eoshift2 be of type index_type 2017-11-22 22:42:39 +02:00
io PR libgfortran/83649 Chunk large reads and writes 2018-01-02 15:25:10 +02:00
m4 re PR fortran/36313 ([F03] {MIN,MAX}{LOC,VAL} should accept character arguments) 2017-12-03 20:14:05 +00:00
runtime PR 53796 Improve INQUIRE(RECL=...) handling 2017-11-28 21:28:50 +02:00
acinclude.m4 Enable building libgfortran with Intel CET 2017-11-17 23:44:59 +01:00
aclocal.m4 Disable hwcaps on libgfortran 2016-12-12 13:40:21 +00:00
c99_protos.h re PR fortran/79305 (real128 - undefined reference to cexpl) 2017-01-31 18:50:31 +00:00
ChangeLog PR libgfortran/83649 Chunk large reads and writes 2018-01-02 15:25:10 +02:00
ChangeLog-2002 ChangeLog-2002: Add copyright footer. 2010-01-04 09:59:59 +01:00
ChangeLog-2003 ChangeLog-2002: Add copyright footer. 2010-01-04 09:59:59 +01:00
ChangeLog-2004 ChangeLog-2002: Add copyright footer. 2010-01-04 09:59:59 +01:00
ChangeLog-2005 ChangeLog-2002: Add copyright footer. 2010-01-04 09:59:59 +01:00
ChangeLog-2006 ChangeLog-2002: Add copyright footer. 2010-01-04 09:59:59 +01:00
ChangeLog-2007 ChangeLog-2002: Add copyright footer. 2010-01-04 09:59:59 +01:00
ChangeLog-2008 ChangeLog-2002: Add copyright footer. 2010-01-04 09:59:59 +01:00
ChangeLog-2009 ChangeLog-2002: Add copyright footer. 2010-01-04 09:59:59 +01:00
ChangeLog-2010 Rotate ChangeLogs. 2011-01-02 08:22:05 -08:00
ChangeLog-2011 2012-01-09 Richard Guenther <rguenther@suse.de> 2012-01-09 10:11:38 +00:00
ChangeLog-2012 ChangeLog rotation. 2013-01-03 10:47:48 +01:00
ChangeLog-2013 Rotate ChangeLog for 2013. 2014-06-17 06:55:59 +03:00
ChangeLog-2014 Update copyright years. 2016-01-04 15:30:50 +01:00
ChangeLog-2015 Update copyright years. 2016-01-04 15:30:50 +01:00
ChangeLog-2016 Update copyright years. 2017-01-01 13:07:43 +01:00
config.h.in re PR libfortran/78379 (Processor-specific versions for matmul) 2017-05-25 21:51:27 +00:00
configure Enable building libgfortran with Intel CET 2017-11-17 23:44:59 +01:00
configure.ac Enable building libgfortran with Intel CET 2017-11-17 23:44:59 +01:00
configure.host re PR target/78478 (Compile Error for i386-rtems) 2017-01-19 22:00:53 +01:00
gfortran.map re PR fortran/36313 ([F03] {MIN,MAX}{LOC,VAL} should accept character arguments) 2017-12-03 20:14:05 +00:00
kinds-override.h Update copyright years. 2017-01-01 13:07:43 +01:00
libgfortran.h PR 53796 Improve INQUIRE(RECL=...) handling 2017-11-28 21:28:50 +02:00
libgfortran.spec.in re PR fortran/32049 (Support on x86_64 also kind=16) 2010-11-16 22:23:19 +01:00
libtool-version re PR fortran/34640 (ICE when assigning item of a derived-component to a pointer) 2017-09-10 17:02:53 +00:00
Makefile.am re PR fortran/36313 ([F03] {MIN,MAX}{LOC,VAL} should accept character arguments) 2017-12-03 20:14:05 +00:00
Makefile.in re PR fortran/36313 ([F03] {MIN,MAX}{LOC,VAL} should accept character arguments) 2017-12-03 20:14:05 +00:00
mk-kinds-h.sh re PR fortran/32049 (Support on x86_64 also kind=16) 2010-11-16 22:23:19 +01:00
mk-sik-inc.sh mk-sik-inc.sh: Make -Wunused-variable proof. 2008-09-10 19:18:08 +02:00
mk-srk-inc.sh intrinsic.h (gfc_check_selected_real_kind, [...]): Update prototypes. 2010-06-25 21:40:37 +02:00