svn commit: r268987 - head/lib/libc/stdio

Pedro F. Giffuni pfg at FreeBSD.org
Tue Jul 22 18:38:00 UTC 2014


Author: pfg
Date: Tue Jul 22 18:37:59 2014
New Revision: 268987
URL: http://svnweb.freebsd.org/changeset/base/268987

Log:
  Revert	r268984:
  Check for __SAPP flag before calling sflush.   This avoids
  performance degradation compared to the previous approach.
  
  Submitted by:	ache
  MFC after:	2 weeks

Modified:
  head/lib/libc/stdio/ftell.c

Modified: head/lib/libc/stdio/ftell.c
==============================================================================
--- head/lib/libc/stdio/ftell.c	Tue Jul 22 17:30:05 2014	(r268986)
+++ head/lib/libc/stdio/ftell.c	Tue Jul 22 18:37:59 2014	(r268987)
@@ -97,8 +97,6 @@ _ftello(FILE *fp, fpos_t *offset)
 	 * Find offset of underlying I/O object, then
 	 * adjust for buffered bytes.
 	 */
-	if (__sflush(fp))	/* may adjust seek offset on append stream */
-		return (1);
 	if (fp->_flags & __SOFF)
 		pos = fp->_offset;
 	else {
@@ -120,6 +118,11 @@ _ftello(FILE *fp, fpos_t *offset)
 		if (HASUB(fp))
 			pos -= fp->_r;  /* Can be negative at this point. */
 	} else if ((fp->_flags & __SWR) && fp->_p != NULL) {
+		if (fp->_flags & __SAPP) {
+			pos = _sseek(fp, (fpos_t)0, SEEK_END);
+			if (pos == -1)
+				return (1);
+		}
 		/*
 		 * Writing.  Any buffered characters cause the
 		 * position to be greater than that in the


More information about the svn-src-all mailing list