diff options
author | Eric Blake <eblake@redhat.com> | 2007-06-04 18:10:17 +0000 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2007-06-04 18:10:17 +0000 |
commit | 17c61d6a2c4868260c1ef3043e03f86de14f6a08 (patch) | |
tree | c795768b8f7d0fa0048f5bd77f6dad9c5ce069e1 /newlib/libc/stdio/stdio.c | |
parent | 6a3b4eb69a7d2b1e1c19a8baef42ce6dc3d61a86 (diff) | |
download | cygnal-17c61d6a2c4868260c1ef3043e03f86de14f6a08.tar.gz cygnal-17c61d6a2c4868260c1ef3043e03f86de14f6a08.tar.bz2 cygnal-17c61d6a2c4868260c1ef3043e03f86de14f6a08.zip |
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.
Diffstat (limited to 'newlib/libc/stdio/stdio.c')
-rw-r--r-- | newlib/libc/stdio/stdio.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/newlib/libc/stdio/stdio.c b/newlib/libc/stdio/stdio.c index 8bc736088..3cf3ea728 100644 --- a/newlib/libc/stdio/stdio.c +++ b/newlib/libc/stdio/stdio.c @@ -30,9 +30,10 @@ */ _READ_WRITE_RETURN_TYPE -_DEFUN(__sread, (cookie, buf, n), - _PTR cookie _AND - char *buf _AND +_DEFUN(__sread, (ptr, cookie, buf, n), + struct _reent *ptr _AND + void *cookie _AND + char *buf _AND int n) { register FILE *fp = (FILE *) cookie; @@ -44,7 +45,7 @@ _DEFUN(__sread, (cookie, buf, n), oldmode = setmode (fp->_file, O_BINARY); #endif - ret = _read_r (_REENT, fp->_file, buf, n); + ret = _read_r (ptr, fp->_file, buf, n); #ifdef __SCLE if (oldmode) @@ -61,9 +62,10 @@ _DEFUN(__sread, (cookie, buf, n), } _READ_WRITE_RETURN_TYPE -_DEFUN(__swrite, (cookie, buf, n), - _PTR cookie _AND - char _CONST *buf _AND +_DEFUN(__swrite, (ptr, cookie, buf, n), + struct _reent *ptr _AND + void *cookie _AND + char const *buf _AND int n) { register FILE *fp = (FILE *) cookie; @@ -73,7 +75,7 @@ _DEFUN(__swrite, (cookie, buf, n), #endif if (fp->_flags & __SAPP) - _CAST_VOID _lseek_r (_REENT, fp->_file, (_off_t) 0, SEEK_END); + _lseek_r (ptr, fp->_file, (_off_t) 0, SEEK_END); fp->_flags &= ~__SOFF; /* in case O_APPEND mode is set */ #ifdef __SCLE @@ -81,7 +83,7 @@ _DEFUN(__swrite, (cookie, buf, n), oldmode = setmode (fp->_file, O_BINARY); #endif - w = _write_r (_REENT, fp->_file, buf, n); + w = _write_r (ptr, fp->_file, buf, n); #ifdef __SCLE if (oldmode) @@ -92,15 +94,16 @@ _DEFUN(__swrite, (cookie, buf, n), } _fpos_t -_DEFUN(__sseek, (cookie, offset, whence), - _PTR cookie _AND +_DEFUN(__sseek, (ptr, cookie, offset, whence), + struct _reent *ptr _AND + void *cookie _AND _fpos_t offset _AND int whence) { register FILE *fp = (FILE *) cookie; register _off_t ret; - ret = _lseek_r (_REENT, fp->_file, (_off_t) offset, whence); + ret = _lseek_r (ptr, fp->_file, (_off_t) offset, whence); if (ret == -1L) fp->_flags &= ~__SOFF; else @@ -112,20 +115,22 @@ _DEFUN(__sseek, (cookie, offset, whence), } int -_DEFUN(__sclose, (cookie), - _PTR cookie) +_DEFUN(__sclose, (ptr, cookie), + struct _reent *ptr _AND + void *cookie) { FILE *fp = (FILE *) cookie; - return _close_r (_REENT, fp->_file); + return _close_r (ptr, fp->_file); } #ifdef __SCLE int -_DEFUN(__stextmode, (fd), +_DEFUN(__stextmode, (fd), int fd) { #ifdef __CYGWIN__ + extern int _cygwin_istext_for_stdio (int); return _cygwin_istext_for_stdio (fd); #else return 0; |