From d6852ac6f1dfc1396dee130993f8686cf53f5d2c Mon Sep 17 00:00:00 2001 From: ache Date: Sat, 24 Oct 2015 02:23:15 +0000 Subject: 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(). MFC after: 3 weeks --- lib/libc/stdio/fopen.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/libc/stdio/fopen.c') diff --git a/lib/libc/stdio/fopen.c b/lib/libc/stdio/fopen.c index b08e336..b26f637 100644 --- a/lib/libc/stdio/fopen.c +++ b/lib/libc/stdio/fopen.c @@ -91,7 +91,10 @@ fopen(const char * __restrict file, const char * __restrict mode) * we can do about this. (We could set __SAPP and check in * fseek and ftell.) */ - if (oflags & O_APPEND) + if (oflags & O_APPEND) { + /* XXX: Reuse __SALC for O_APPEND. */ + fp->_flags |= __SALC; (void)_sseek(fp, (fpos_t)0, SEEK_END); + } return (fp); } -- cgit v1.1 From 64dac23af83b727e5f33d41dc5ecb1444c8c0c30 Mon Sep 17 00:00:00 2001 From: ache Date: Wed, 28 Oct 2015 14:40:02 +0000 Subject: Add _flags2 per jhb@ suggestion since no room left in _flags. Rewrite O_APPEND flag checking using new __S2OAP flag. MFC after: 3 weeks --- lib/libc/stdio/fopen.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/libc/stdio/fopen.c') diff --git a/lib/libc/stdio/fopen.c b/lib/libc/stdio/fopen.c index b26f637..9ab61ba 100644 --- a/lib/libc/stdio/fopen.c +++ b/lib/libc/stdio/fopen.c @@ -92,8 +92,7 @@ fopen(const char * __restrict file, const char * __restrict mode) * fseek and ftell.) */ if (oflags & O_APPEND) { - /* XXX: Reuse __SALC for O_APPEND. */ - fp->_flags |= __SALC; + fp->_flags2 |= __S2OAP; (void)_sseek(fp, (fpos_t)0, SEEK_END); } return (fp); -- cgit v1.1