OSDN Git Service

2011-10-18 Tobias Burnus <burnus@net-b.de>
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 18 Oct 2011 12:58:42 +0000 (12:58 +0000)
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 18 Oct 2011 12:58:42 +0000 (12:58 +0000)
            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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@180138 138bc75d-0d04-0410-961f-82ee72b054a4

libgfortran/ChangeLog
libgfortran/io/file_pos.c
libgfortran/io/inquire.c
libgfortran/io/intrinsics.c
libgfortran/io/unix.c

index f4561ca..55a7370 100644 (file)
@@ -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
index b034f38..4efdc1f 100644 (file)
@@ -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
index 252f29f..97bd9b6 100644 (file)
@@ -409,7 +409,10 @@ inquire_via_unit (st_parameter_inquire *iqp, gfc_unit * 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);
+           }
        }
     }
 
index f48bd77..eaf2e17 100644 (file)
@@ -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);
        }
     }
index 12536ca..79bb9e9 100644 (file)
@@ -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);