aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJanne Blomqvist <jb@gcc.gnu.org>2016-10-15 16:14:15 +0300
committerJanne Blomqvist <jb@gcc.gnu.org>2016-10-15 16:14:15 +0300
commitc04d4ede178fcb2e1d216ebf616786ca8c6cbe1c (patch)
tree05afbe2773ef57d4fffd38d55a4f9a577ac6e90f /gcc
parent64190f049ac8117b403b038ca35bc771132b6e73 (diff)
downloadgcc-c04d4ede178fcb2e1d216ebf616786ca8c6cbe1c.zip
gcc-c04d4ede178fcb2e1d216ebf616786ca8c6cbe1c.tar.gz
gcc-c04d4ede178fcb2e1d216ebf616786ca8c6cbe1c.tar.bz2
PR 48587 Newunit allocator
Currently GFortran newer reuses unit numbers allocated with NEWUNIT=, instead having a simple counter that is decremented each time such a unit is opened. For a long running program which repeatedly opens files with NEWUNIT= and closes them, the counter can wrap around and cause an abort. This patch replaces the counter with an allocator that keeps track of which units numbers are allocated, and can reuse them once they have been deallocated. Since operating systems tend to limit the number of simultaneous open files for a process to a relatively modest number, a relatively simple approach with a linear scan through an array suffices. Though as a small optimization there is a low water indicator keeping track of the index for which all unit numbers below are already allocated. This linear scan also ensures that we always allocate the smallest available unit number. 2016-10-15 Janne Blomqvist <jb@gcc.gnu.org> PR libfortran/48587 * io/io.h (get_unique_unit_number): Remove prototype. (newunit_alloc): New prototype. * io/open.c (st_open): Call newunit_alloc. * io/unit.c (newunits,newunit_size,newunit_lwi): New static variables. (GFC_FIRST_NEWUNIT): Rename to NEWUNIT_START. (next_available_newunit): Remove variable. (get_unit): Call newunit_alloc, don't try to create negative external unit. (close_unit_1): Call newunit_free. (close_units): Free newunits array. (get_unique_number): Remove function. (newunit_alloc): New function. (newunit_free): New function. * io/transfer.c (data_transfer_init): Check for invalid unit number. testsuite ChangeLog: 2016-10-15 Janne Blomqvist <jb@gcc.gnu.org> PR libfortran/48587 * gfortran.dg/negative_unit2.f90: New testcase. From-SVN: r241199
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog5
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 849c6e4..0e48772 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-10-15 Janne Blomqvist <jb@gcc.gnu.org>
+
+ PR libfortran/48587
+ * gfortran.dg/negative_unit2.f90: New test.
+
2016-10-14 Jakub Jelinek <jakub@redhat.com>
PR middle-end/77959