From 8ebe0f53597789057018d353c2b38b45470ea16e Mon Sep 17 00:00:00 2001 From: "Andrey A. Chernov" Date: Sun, 8 Nov 2015 13:37:16 +0000 Subject: MFC: r289863,r289931,r290110,r290230,r290231,r290232 r290232: Microoptimize. r290231: Addition to prev. commit. In some edge cases fp->_p can be changed in _sseek(), recalculate. r290230: Don't seek to the end if write buffer is empty (in append modes). PR: 204156 r290110: Add _flags2 per jhb@ suggestion since no room left in _flags. Rewrite O_APPEND flag checking using new __S2OAP flag. r289931: According to POSIX, a write operation shall start at the current size of the stream (if mode had 'a' as the first character). r289863: Since no room left in the _flags, reuse __SALC for O_APPEND. It helps to remove _fcntl() call from _ftello() and optimize seek position calculation in _swrite(). --- lib/libc/stdio/stdio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libc/stdio/stdio.c') diff --git a/lib/libc/stdio/stdio.c b/lib/libc/stdio/stdio.c index 44ee0ab41210..5d6fb9ac5644 100644 --- a/lib/libc/stdio/stdio.c +++ b/lib/libc/stdio/stdio.c @@ -117,7 +117,7 @@ _swrite(FILE *fp, char const *buf, int n) ret = (*fp->_write)(fp->_cookie, buf, n); /* __SOFF removed even on success in case O_APPEND mode is set. */ if (ret >= 0) { - if ((fp->_flags & (__SAPP|__SOFF)) == (__SAPP|__SOFF) && + if ((fp->_flags & __SOFF) && !(fp->_flags2 & __S2OAP) && fp->_offset <= OFF_MAX - ret) fp->_offset += ret; else -- cgit v1.2.3