From 17c61d6a2c4868260c1ef3043e03f86de14f6a08 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Mon, 4 Jun 2007 18:10:17 +0000 Subject: Implement funopen, fopencookie. * libc/include/sys/reent.h (struct __sFILE, struct __sFILE64): Switch to reentrant callbacks. * libc/include/stdio.h (funopen): Fix declaration. (fopencookie): Declare. * libc/stdio/local.h (__sread, __swrite, __sseek, __sclose) (__sseek64, __swrite64): Fix prototypes. [__SCLE]: Pull in setmode declaration. * libc/stdio/stdio.c (__sread, __swrite, __sseek, __sclose): Fix reentrancy. * libc/stdio64/stdio64.c (__sseek64_r, __swrite64_r): Delete. (__sseek64, __swrite64): Fix reentrancy. * libc/stdio/fseek.c (_fseek_r): Account for overflow, and fix reentrancy. * libc/stdio/ftell.c (_ftell_r): Likewise. * libc/stdio/flags.c (__sflags): Don't lose __SAPP on "a+". * libc/stdio/fclose.c (_fclose_r): Fix reentrancy. * libc/stdio/freopen.c (_freopen_r): Likewise. * libc/stdio/fvwrite.c (__sfvwrite_r): Likewise. * libc/stdio/refill.c (__srefill_r): Likewise. * libc/stdio/siscanf.c (eofread): Likewise. * libc/stdio/sscanf.c (eofread): Likewise. * libc/stdio/vsiscanf.c (eofread1): Likewise. * libc/stdio/vsscanf.c (eofread1): Likewise. * libc/stdio64/freopen64.c (_freopen64_r): Likewise. * libc/stdio64/fseeko64.c (_fseeko64_r): Likewise. * libc/stdio64/ftello64.c (_ftello64_r): Likewise. * libc/stdio/fflush.c (fflush): Improve reentrancy, although more could be fixed. * libc/stdio/fopencookie.c (_fopencookie_r, fopencookie): New file. * libc/stdio/funopen.c (_funopen_r, funopen): New file. * libc/stdio/Makefile.am (ELIX_4_SOURCES, CHEWOUT_FILES): Build new files. * libc/stdio/Makefile.in: Regenerate. --- newlib/libc/stdio64/fseeko64.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'newlib/libc/stdio64/fseeko64.c') diff --git a/newlib/libc/stdio64/fseeko64.c b/newlib/libc/stdio64/fseeko64.c index 33e22dcc5..fe07bfe2d 100644 --- a/newlib/libc/stdio64/fseeko64.c +++ b/newlib/libc/stdio64/fseeko64.c @@ -104,7 +104,7 @@ _DEFUN (_fseeko64_r, (ptr, fp, offset, whence), _off64_t offset _AND int whence) { - _fpos64_t _EXFUN ((*seekfn), (void *, _fpos64_t, int)); + _fpos64_t _EXFUN ((*seekfn), (struct _reent *, void *, _fpos64_t, int)); _fpos64_t target, curoff; size_t n; @@ -155,7 +155,7 @@ _DEFUN (_fseeko64_r, (ptr, fp, offset, whence), curoff = fp->_offset; else { - curoff = (*seekfn) (fp->_cookie, (_fpos64_t) 0, SEEK_CUR); + curoff = seekfn (ptr, fp->_cookie, (_fpos64_t) 0, SEEK_CUR); if (curoff == -1L) { _funlockfile(fp); @@ -238,7 +238,7 @@ _DEFUN (_fseeko64_r, (ptr, fp, offset, whence), curoff = fp->_offset; else { - curoff = (*seekfn) (fp->_cookie, (_fpos64_t)0, SEEK_CUR); + curoff = seekfn (ptr, fp->_cookie, (_fpos64_t)0, SEEK_CUR); if (curoff == POS_ERR) goto dumb; } @@ -299,7 +299,7 @@ _DEFUN (_fseeko64_r, (ptr, fp, offset, whence), */ curoff = target & ~((_fpos64_t)(fp->_blksize - 1)); - if ((*seekfn) (fp->_cookie, curoff, SEEK_SET) == POS_ERR) + if (seekfn (ptr, fp->_cookie, curoff, SEEK_SET) == POS_ERR) goto dumb; fp->_r = 0; fp->_p = fp->_bf._base; @@ -323,7 +323,7 @@ _DEFUN (_fseeko64_r, (ptr, fp, offset, whence), */ dumb: - if (fflush (fp) || (*seekfn) (fp->_cookie, offset, whence) == POS_ERR) + if (fflush (fp) || seekfn (ptr, fp->_cookie, offset, whence) == POS_ERR) { _funlockfile(fp); return EOF; -- cgit v1.2.3