diff options
author | Thomas Fitzsimmons <fitzsim@redhat.com> | 2002-05-08 04:12:49 +0400 |
---|---|---|
committer | Thomas Fitzsimmons <fitzsim@redhat.com> | 2002-05-08 04:12:49 +0400 |
commit | e71372faea4af670215b087a69c2b7432181a852 (patch) | |
tree | 5adf28cd89c62937515cb7362e878ec45b51d190 /newlib/libc/stdio/ftell.c | |
parent | 735bb7e7d7c52aedc7099411ef235fee206e7240 (diff) |
* libc/include/sys/stdio.h: New file.
* libc/sys/linux/sys/stdio.h: New file.
* libc/include/stdio.h: Add declarations for flockfile,
ftrylockfile, and funlockfile. Include <sys/stdio.h>.
* libc/stdio/clearerr.c: Add file locking.
* libc/stdio/fclose.c: Likewise.
* libc/stdio/feof.c: Likewise.
* libc/stdio/ferror.c: Likewise.
* libc/stdio/fflush.c: Likewise.
* libc/stdio/fgetc.c: Likewise.
* libc/stdio/fgetpos.c: Likewise.
* libc/stdio/fgets.c: Likewise.
* libc/stdio/fileno.c: Likewise.
* libc/stdio/fputc.c: Likewise.
* libc/stdio/fputs.c: Likewise.
* libc/stdio/fread.c: Likewise.
* libc/stdio/freopen.c: Likewise.
* libc/stdio/fseek.c: Likewise.
* libc/stdio/ftell.c: Likewise.
* libc/stdio/fwrite.c: Likewise.
* libc/stdio/getc.c: Likewise.
* libc/stdio/putc.c: Likewise.
* libc/stdio/setvbuf.c: Likewise.
* libc/stdio/ungetc.c: Likewise.
* libc/stdio/vfprintf.c: Likewise.
Diffstat (limited to 'newlib/libc/stdio/ftell.c')
-rw-r--r-- | newlib/libc/stdio/ftell.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/newlib/libc/stdio/ftell.c b/newlib/libc/stdio/ftell.c index 6a8061816..8066acc3b 100644 --- a/newlib/libc/stdio/ftell.c +++ b/newlib/libc/stdio/ftell.c @@ -80,6 +80,8 @@ _DEFUN (ftell, (fp), { fpos_t pos; + _flockfile(fp); + /* Ensure stdio is set up. */ CHECK_INIT (fp); @@ -87,6 +89,7 @@ _DEFUN (ftell, (fp), if (fp->_seek == NULL) { fp->_data->_errno = ESPIPE; + _funlockfile(fp); return -1L; } @@ -99,7 +102,10 @@ _DEFUN (ftell, (fp), { pos = (*fp->_seek) (fp->_cookie, (fpos_t) 0, SEEK_CUR); if (pos == -1L) - return pos; + { + _funlockfile(fp); + return pos; + } } if (fp->_flags & __SRD) { @@ -122,5 +128,6 @@ _DEFUN (ftell, (fp), pos += fp->_p - fp->_bf._base; } + _funlockfile(fp); return pos; } |