diff options
Diffstat (limited to 'gcc-4.6/libgfortran/io/unix.c')
-rw-r--r-- | gcc-4.6/libgfortran/io/unix.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/gcc-4.6/libgfortran/io/unix.c b/gcc-4.6/libgfortran/io/unix.c index 12536ca..26bb06a 100644 --- a/gcc-4.6/libgfortran/io/unix.c +++ b/gcc-4.6/libgfortran/io/unix.c @@ -435,10 +435,6 @@ buf_flush (unix_stream * s) if (s->ndirty != 0) return -1; -#ifdef _WIN32 - _commit (s->fd); -#endif - return 0; } @@ -1526,6 +1522,23 @@ retry: return u; } + +/* Flush dirty data, making sure that OS metadata is updated as + well. Note that this is VERY slow on mingw due to committing data + to stable storage. */ +int +flush_sync (stream * s) +{ + if (sflush (s) == -1) + return -1; +#ifdef __MINGW32__ + if (_commit (((unix_stream *)s)->fd) == -1) + return -1; +#endif + return 0; +} + + static gfc_unit * flush_all_units_1 (gfc_unit *u, int min_unit) { @@ -1542,7 +1555,7 @@ flush_all_units_1 (gfc_unit *u, int min_unit) if (__gthread_mutex_trylock (&u->lock)) return u; if (u->s) - sflush (u->s); + flush_sync (u->s); __gthread_mutex_unlock (&u->lock); } u = u->right; @@ -1572,7 +1585,7 @@ flush_all_units (void) if (u->closed == 0) { - sflush (u->s); + flush_sync (u->s); __gthread_mutex_lock (&unit_lock); __gthread_mutex_unlock (&u->lock); (void) predec_waiting_locked (u); |