diff options
Diffstat (limited to 'newlib/libc/stdio64')
-rw-r--r-- | newlib/libc/stdio64/freopen64.c | 2 | ||||
-rw-r--r-- | newlib/libc/stdio64/fseeko64.c | 22 | ||||
-rw-r--r-- | newlib/libc/stdio64/ftello64.c | 6 | ||||
-rw-r--r-- | newlib/libc/stdio64/tmpfile64.c | 1 |
4 files changed, 24 insertions, 7 deletions
diff --git a/newlib/libc/stdio64/freopen64.c b/newlib/libc/stdio64/freopen64.c index 0362407e9..866d8c943 100644 --- a/newlib/libc/stdio64/freopen64.c +++ b/newlib/libc/stdio64/freopen64.c @@ -124,7 +124,7 @@ _DEFUN (_freopen64_r, (ptr, file, mode, fp), else { if (fp->_flags & __SWR) - fflush (fp); + _fflush_r (ptr, fp); /* * If close is NULL, closing is a no-op, hence pointless. * If file is NULL, the file should not be closed. diff --git a/newlib/libc/stdio64/fseeko64.c b/newlib/libc/stdio64/fseeko64.c index fe07bfe2d..280484e62 100644 --- a/newlib/libc/stdio64/fseeko64.c +++ b/newlib/libc/stdio64/fseeko64.c @@ -111,11 +111,22 @@ _DEFUN (_fseeko64_r, (ptr, fp, offset, whence), struct stat64 st; int havepos; + /* Only do 64-bit seek on large file. */ + if (!(fp->_flags & __SL64)) + { + if ((_off_t) offset != offset) + { + ptr->_errno = EOVERFLOW; + return EOF; + } + return (_off64_t) _fseeko_r (ptr, fp, offset, whence); + } + /* Make sure stdio is set up. */ CHECK_INIT (ptr, fp); - _flockfile(fp); + _flockfile (fp); curoff = fp->_offset; @@ -125,12 +136,12 @@ _DEFUN (_fseeko64_r, (ptr, fp, offset, whence), if (fp->_flags & __SAPP && fp->_flags & __SWR) { /* So flush the buffer and seek to the end. */ - fflush (fp); + _fflush_r (ptr, fp); } /* Have to be able to seek. */ - if ((seekfn = fp->_seek64) == NULL || !(fp->_flags & __SL64)) + if ((seekfn = fp->_seek64) == NULL) { ptr->_errno = ESPIPE; /* ??? */ _funlockfile(fp); @@ -150,7 +161,7 @@ _DEFUN (_fseeko64_r, (ptr, fp, offset, whence), * we have to first find the current stream offset a la * ftell (see ftell for details). */ - fflush(fp); /* may adjust seek offset on append stream */ + _fflush_r (ptr, fp); /* may adjust seek offset on append stream */ if (fp->_flags & __SOFF) curoff = fp->_offset; else @@ -323,7 +334,8 @@ _DEFUN (_fseeko64_r, (ptr, fp, offset, whence), */ dumb: - if (fflush (fp) || seekfn (ptr, fp->_cookie, offset, whence) == POS_ERR) + if (_fflush_r (ptr, fp) + || seekfn (ptr, fp->_cookie, offset, whence) == POS_ERR) { _funlockfile(fp); return EOF; diff --git a/newlib/libc/stdio64/ftello64.c b/newlib/libc/stdio64/ftello64.c index b596d3234..2fdfb784e 100644 --- a/newlib/libc/stdio64/ftello64.c +++ b/newlib/libc/stdio64/ftello64.c @@ -91,6 +91,10 @@ _DEFUN (_ftello64_r, (ptr, fp), { _fpos64_t pos; + /* Only do 64-bit tell on large file. */ + if (!(fp->_flags & __SL64)) + return (_off64_t) _ftello_r (ptr, fp); + /* Ensure stdio is set up. */ CHECK_INIT (ptr, fp); @@ -106,7 +110,7 @@ _DEFUN (_ftello64_r, (ptr, fp), /* Find offset of underlying I/O object, then adjust for buffered bytes. */ - fflush(fp); /* may adjust seek offset on append stream */ + _fflush_r (ptr, fp); /* may adjust seek offset on append stream */ if (fp->_flags & __SOFF) pos = fp->_offset; else diff --git a/newlib/libc/stdio64/tmpfile64.c b/newlib/libc/stdio64/tmpfile64.c index 511606c78..98a7d7817 100644 --- a/newlib/libc/stdio64/tmpfile64.c +++ b/newlib/libc/stdio64/tmpfile64.c @@ -48,6 +48,7 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<getpid>>, */ #include <stdio.h> +#include <reent.h> #include <errno.h> #include <fcntl.h> #include <sys/stat.h> |