From e71372faea4af670215b087a69c2b7432181a852 Mon Sep 17 00:00:00 2001 From: Thomas Fitzsimmons Date: Wed, 8 May 2002 00:12:49 +0000 Subject: * 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 . * 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. --- newlib/libc/stdio/fseek.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'newlib/libc/stdio/fseek.c') diff --git a/newlib/libc/stdio/fseek.c b/newlib/libc/stdio/fseek.c index 1b7298914..10c6c532e 100644 --- a/newlib/libc/stdio/fseek.c +++ b/newlib/libc/stdio/fseek.c @@ -96,6 +96,8 @@ fseek (fp, offset, whence) struct stat st; int havepos; + _flockfile(fp); + /* Make sure stdio is set up. */ CHECK_INIT (fp); @@ -115,6 +117,7 @@ fseek (fp, offset, whence) if ((seekfn = fp->_seek) == NULL) { ptr->_errno = ESPIPE; /* ??? */ + _funlockfile(fp); return EOF; } @@ -138,6 +141,7 @@ fseek (fp, offset, whence) { curoff = (*seekfn) (fp->_cookie, (fpos_t) 0, SEEK_CUR); if (curoff == -1L) + _funlockfile(fp); return EOF; } if (fp->_flags & __SRD) @@ -161,6 +165,7 @@ fseek (fp, offset, whence) default: ptr->_errno = EINVAL; + _funlockfile(fp); return (EOF); } @@ -262,6 +267,7 @@ fseek (fp, offset, whence) if (HASUB (fp)) FREEUB (fp); fp->_flags &= ~__SEOF; + _funlockfile(fp); return 0; } @@ -290,6 +296,7 @@ fseek (fp, offset, whence) fp->_p += n; fp->_r -= n; } + _funlockfile(fp); return 0; /* @@ -299,7 +306,10 @@ fseek (fp, offset, whence) dumb: if (fflush (fp) || (*seekfn) (fp->_cookie, offset, whence) == POS_ERR) - return EOF; + { + _funlockfile(fp); + return EOF; + } /* success: clear EOF indicator and discard ungetc() data */ if (HASUB (fp)) FREEUB (fp); @@ -307,5 +317,6 @@ dumb: fp->_r = 0; /* fp->_w = 0; *//* unnecessary (I think...) */ fp->_flags &= ~__SEOF; + _funlockfile(fp); return 0; } -- cgit v1.2.3