Mercurial > hg > CbC > CbC_gcc
diff libgfortran/io/file_pos.c @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
line wrap: on
line diff
--- a/libgfortran/io/file_pos.c Fri Oct 27 22:46:09 2017 +0900 +++ b/libgfortran/io/file_pos.c Thu Oct 25 07:37:49 2018 +0900 @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2017 Free Software Foundation, Inc. +/* Copyright (C) 2002-2018 Free Software Foundation, Inc. Contributed by Andy Vaught and Janne Blomqvist This file is part of the GNU Fortran runtime library (libgfortran). @@ -25,6 +25,7 @@ #include "io.h" #include "fbuf.h" #include "unix.h" +#include "async.h" #include <string.h> /* file_pos.c-- Implement the file positioning statements, i.e. BACKSPACE, @@ -187,6 +188,7 @@ st_backspace (st_parameter_filepos *fpp) { gfc_unit *u; + bool needs_unlock = false; library_start (&fpp->common); @@ -214,6 +216,17 @@ goto done; } + if (ASYNC_IO && u->au) + { + if (async_wait (&(fpp->common), u->au)) + return; + else + { + needs_unlock = true; + LOCK (&u->au->io_lock); + } + } + /* Make sure format buffer is flushed and reset. */ if (u->flags.form == FORM_FORMATTED) { @@ -267,7 +280,12 @@ done: if (u != NULL) - unlock_unit (u); + { + unlock_unit (u); + + if (ASYNC_IO && u->au && needs_unlock) + UNLOCK (&u->au->io_lock); + } library_end (); } @@ -280,6 +298,7 @@ st_endfile (st_parameter_filepos *fpp) { gfc_unit *u; + bool needs_unlock = false; library_start (&fpp->common); @@ -294,6 +313,17 @@ goto done; } + if (ASYNC_IO && u->au) + { + if (async_wait (&(fpp->common), u->au)) + return; + else + { + needs_unlock = true; + LOCK (&u->au->io_lock); + } + } + if (u->flags.access == ACCESS_SEQUENTIAL && u->endfile == AFTER_ENDFILE) { @@ -376,8 +406,11 @@ } } - done: - unlock_unit (u); + done: + if (ASYNC_IO && u->au && needs_unlock) + UNLOCK (&u->au->io_lock); + + unlock_unit (u); library_end (); } @@ -390,6 +423,7 @@ st_rewind (st_parameter_filepos *fpp) { gfc_unit *u; + bool needs_unlock = true; library_start (&fpp->common); @@ -401,6 +435,17 @@ "Cannot REWIND a file opened for DIRECT access"); else { + if (ASYNC_IO && u->au) + { + if (async_wait (&(fpp->common), u->au)) + return; + else + { + needs_unlock = true; + LOCK (&u->au->io_lock); + } + } + /* If there are previously written bytes from a write with ADVANCE="no", add a record marker before performing the ENDFILE. */ @@ -436,6 +481,10 @@ } /* Update position for INQUIRE. */ u->flags.position = POSITION_REWIND; + + if (ASYNC_IO && u->au && needs_unlock) + UNLOCK (&u->au->io_lock); + unlock_unit (u); } @@ -450,12 +499,24 @@ st_flush (st_parameter_filepos *fpp) { gfc_unit *u; + bool needs_unlock = false; library_start (&fpp->common); u = find_unit (fpp->common.unit); if (u != NULL) { + if (ASYNC_IO && u->au) + { + if (async_wait (&(fpp->common), u->au)) + return; + else + { + needs_unlock = true; + LOCK (&u->au->io_lock); + } + } + /* Make sure format buffer is flushed. */ if (u->flags.form == FORM_FORMATTED) fbuf_flush (u, u->mode); @@ -469,5 +530,8 @@ generate_error (&fpp->common, LIBERROR_BAD_OPTION, "Specified UNIT in FLUSH is not connected"); + if (needs_unlock) + UNLOCK (&u->au->io_lock); + library_end (); }