summaryrefslogtreecommitdiff
path: root/libgfortran/io
diff options
context:
space:
mode:
authorjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2006-02-24 18:16:25 +0000
committerjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2006-02-24 18:16:25 +0000
commitb3ac10328825374472101a4fcb138a9aa7913e8c (patch)
tree5e671113bd77714f30e86a5773c4f55f1480218f /libgfortran/io
parentfb8ce8543fb3e8739601a295a9932532371e5240 (diff)
downloadgcc-b3ac10328825374472101a4fcb138a9aa7913e8c.tar.gz
2006-02-24 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/26423 * io/unix.c (fd_seek): Revert change from 25949. (fd_read): Same. (fd_write): Same. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@111420 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/io')
-rw-r--r--libgfortran/io/unix.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index 40ad2d897bb..1293b24c9db 100644
--- a/libgfortran/io/unix.c
+++ b/libgfortran/io/unix.c
@@ -562,9 +562,15 @@ fd_sfree (unix_stream * s)
static try
fd_seek (unix_stream * s, gfc_offset offset)
{
- s->logical_offset = offset;
+ if (s->physical_offset == offset) /* Are we lucky and avoid syscall? */
+ {
+ s->logical_offset = offset;
+ return SUCCESS;
+ }
- return SUCCESS;
+ s->physical_offset = s->logical_offset = offset;
+
+ return (lseek (s->fd, offset, SEEK_SET) < 0) ? FAILURE : SUCCESS;
}
@@ -666,8 +672,7 @@ fd_read (unix_stream * s, void * buf, size_t * nbytes)
return errno;
}
- if (is_seekable ((stream *) s) && s->physical_offset != s->logical_offset
- && lseek (s->fd, s->logical_offset, SEEK_SET) < 0)
+ if (is_seekable ((stream *) s) && fd_seek (s, s->logical_offset) == FAILURE)
{
*nbytes = 0;
return errno;
@@ -715,8 +720,7 @@ fd_write (unix_stream * s, const void * buf, size_t * nbytes)
return errno;
}
- if (is_seekable ((stream *) s) && s->physical_offset != s->logical_offset
- && lseek (s->fd, s->logical_offset, SEEK_SET) < 0)
+ if (is_seekable ((stream *) s) && fd_seek (s, s->logical_offset) == FAILURE)
{
*nbytes = 0;
return errno;