===================================================================
@@ -1,3 +1,14 @@
+2011-10-18 Tobias Burnus <burnus@net-b.de>
+ Janne Blomqvist <jb@gcc.gnu.org>
+
+ PR fortran/50016
+ * io/file_pos.c (st_flush): Call _commit on MinGW(-w64).
+ * io/intrinsics.c (flush_i4, flush_i8): Ditto.
+ * io/unix.c (flush_all_units_1, flush_all_units): Ditto.
+ (buf_flush): Remove _commit call.
+ * io/inquire.c (inquire_via_unit): Flush internal buffer
+ and call file_length instead of invoking stat via file_size.
+
2011-09-11 Thomas Koenig <tkoenig@gcc.gnu.org>
Backport fron trunk
===================================================================
@@ -452,6 +452,10 @@ st_flush (st_parameter_filepos *fpp)
fbuf_flush (u, u->mode);
sflush (u->s);
+#ifdef _WIN32
+ /* Without _commit, changes are not visible to other file descriptors. */
+ _commit (u->s->fd);
+#endif
unlock_unit (u);
}
else
===================================================================
@@ -409,7 +409,10 @@ inquire_via_unit (st_parameter_inquire *iqp, gfc_u
if (u == NULL)
*iqp->size = -1;
else
- *iqp->size = file_size (u->file, (gfc_charlen_type) u->file_len);
+ {
+ sflush (u->s);
+ *iqp->size = file_length (u->s);
+ }
}
}
===================================================================
@@ -435,10 +435,6 @@ buf_flush (unix_stream * s)
if (s->ndirty != 0)
return -1;
-#ifdef _WIN32
- _commit (s->fd);
-#endif
-
return 0;
}
@@ -1542,7 +1538,14 @@ flush_all_units_1 (gfc_unit *u, int min_unit)
if (__gthread_mutex_trylock (&u->lock))
return u;
if (u->s)
- sflush (u->s);
+ {
+ sflush (u->s);
+#ifdef _WIN32
+ /* Without _commit, changes are not visible to other
+ file descriptors. */
+ _commit (u->s->fd);
+#endif
+ }
__gthread_mutex_unlock (&u->lock);
}
u = u->right;
@@ -1573,6 +1576,11 @@ flush_all_units (void)
if (u->closed == 0)
{
sflush (u->s);
+#ifdef _WIN32
+ /* Without _commit, changes are not visible to other
+ file descriptors. */
+ _commit (u->s->fd);
+#endif
__gthread_mutex_lock (&unit_lock);
__gthread_mutex_unlock (&u->lock);
(void) predec_waiting_locked (u);
===================================================================
@@ -207,6 +207,11 @@ flush_i4 (GFC_INTEGER_4 *unit)
if (us != NULL)
{
sflush (us->s);
+#ifdef _WIN32
+ /* Without _commit, changes are not visible
+ to other file descriptors. */
+ _commit (u->s->fd);
+#endif
unlock_unit (us);
}
}
@@ -230,6 +235,11 @@ flush_i8 (GFC_INTEGER_8 *unit)
if (us != NULL)
{
sflush (us->s);
+#ifdef _WIN32
+ /* Without _commit, changes are not visible
+ to other file descriptors. */
+ _commit (u->s->fd);
+#endif
unlock_unit (us);
}
}