+2013-04-10 Bin Cheng <bin.cheng@arm.com>
+ * acconfig.h (_FSEEK_OPTIMIZATION): Undef
+ * newlib.hin (_FSEEK_OPTIMIZATION): Undef
+ * configure.in (--disable-newlib-fseek-optimization): New option.
+ * configure: Regenerated.
+ * libc/stdio/fflush.c (__sflush_r): Use _FSEEK_OPTIMIZATION to
+ control fseek optimization.
+ * libc/stdio/fseeko.c (_fseeko_r): Ditto.
+ * libc/stdio/makebuf.c (__smakebuf_r): Ditto.
+ * libc/stdio64/fseeko64.c (_fseeko64_r): Ditto.
+
2013-04-08 Matthew Gretton-Dann <matthew.gretton-dann@linaro.org>
* libc/stdio/vfieeefp.h (ldieee): Fix typo.
/* Define if ivo supported in streamio. */
#undef _FVWRITE_IN_STREAMIO
+/* Define if fseek functions support seek optimization. */
+#undef _FSEEK_OPTIMIZATION
+
@BOTTOM@
/*
* Iconv encodings enabled ("to" direction)
enable_newlib_atexit_dynamic_alloc
enable_newlib_reent_small
enable_newlib_fvwrite_in_streamio
+enable_newlib_fseek_optimization
enable_multilib
enable_target_optspace
enable_malloc_debugging
--disable-newlib-atexit-alloc disable dynamic allocation of atexit entries
--enable-newlib-reent-small enable small reentrant struct support
--disable-newlib-fvwrite-in-streamio disable iov in streamio
+ --disable-newlib-fseek-optimization disable fseek optimization
--enable-multilib build many library versions (default)
--enable-target-optspace optimize for space
--enable-malloc-debugging indicate malloc debugging requested
newlib_fvwrite_in_streamio=yes
fi
+# Check whether --enable-newlib-fseek-optimization was given.
+if test "${enable_newlib_fseek_optimization+set}" = set; then :
+ enableval=$enable_newlib_fseek_optimization; if test "${newlib_fseek_optimization+set}" != set; then
+ case "${enableval}" in
+ yes) newlib_fseek_optimization=yes ;;
+ no) newlib_fseek_optimization=no ;;
+ *) as_fn_error $? "bad value ${enableval} for newlib-fseek-optimization option" "$LINENO" 5 ;;
+ esac
+ fi
+else
+ newlib_fseek_optimization=yes
+fi
+
# Make sure we can run config.sub.
$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11654 "configure"
+#line 11684 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11760 "configure"
+#line 11790 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
fi
+if test "${newlib_fseek_optimization}" = "yes"; then
+cat >>confdefs.h <<_ACEOF
+#define _FSEEK_OPTIMIZATION 1
+_ACEOF
+
+fi
+
if test "x${iconv_encodings}" != "x" \
|| test "x${iconv_to_encodings}" != "x" \
esac
fi], [newlib_fvwrite_in_streamio=yes])dnl
+dnl Support --disable-newlib-fseek-optimization
+AC_ARG_ENABLE(newlib-fseek-optimization,
+[ --disable-newlib-fseek-optimization disable fseek optimization],
+[if test "${newlib_fseek_optimization+set}" != set; then
+ case "${enableval}" in
+ yes) newlib_fseek_optimization=yes ;;
+ no) newlib_fseek_optimization=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for newlib-fseek-optimization option) ;;
+ esac
+ fi], [newlib_fseek_optimization=yes])dnl
+
NEWLIB_CONFIGURE(.)
dnl We have to enable libtool after NEWLIB_CONFIGURE because if we try and
if test "${newlib_fvwrite_in_streamio}" = "yes"; then
AC_DEFINE_UNQUOTED(_FVWRITE_IN_STREAMIO)
fi
+
+if test "${newlib_fseek_optimization}" = "yes"; then
+AC_DEFINE_UNQUOTED(_FSEEK_OPTIMIZATION)
+fi
dnl
dnl Parse --enable-newlib-iconv-encodings option argument
t = fp->_flags;
if ((t & __SWR) == 0)
{
+#ifdef _FSEEK_OPTIMIZATION
/* For a read stream, an fflush causes the next seek to be
unoptimized (i.e. forces a system-level seek). This conforms
to the POSIX and SUSv3 standards. */
fp->_flags |= __SNPT;
+#endif
/* For a seekable stream with buffered read characters, we will attempt
a seek to the current position now. A subsequent read will then get
{
/* Seek successful or ignorable error condition.
We can clear read buffer now. */
+#ifdef _FSEEK_OPTIMIZATION
fp->_flags &= ~__SNPT;
+#endif
fp->_r = 0;
fp->_p = fp->_bf._base;
if ((fp->_flags & __SOFF) && (curoff != -1 || ptr->_errno == 0))
if (fp->_bf._base == NULL)
__smakebuf_r (ptr, fp);
+
+#ifdef _FSEEK_OPTIMIZATION
if (fp->_flags & (__SWR | __SRW | __SNBF | __SNPT))
goto dumb;
if ((fp->_flags & __SOPT) == 0)
* We get here if we cannot optimise the seek ... just
* do it. Allow the seek function to change fp->_bf._base.
*/
+#endif
dumb:
if (_fflush_r (ptr, fp)
size = _DEFAULT_ASPRINTF_BUFSIZE;
else
size = BUFSIZ;
+#ifdef _FSEEK_OPTIMIZATION
/* do not try to optimise fseek() */
fp->_flags |= __SNPT;
+#endif
}
else
{
#else
size = BUFSIZ;
#endif
+#ifdef _FSEEK_OPTIMIZATION
/*
* Optimize fseek() only if it is a regular file.
* (The test for __sseek is mainly paranoia.)
}
else
fp->_flags |= __SNPT;
+#endif
}
if ((p = _malloc_r (ptr, size)) == NULL)
{
if (fp->_bf._base == NULL)
__smakebuf_r (ptr, fp);
+
+#if _FSEEK_OPTIMIZATION
if (fp->_flags & (__SWR | __SRW | __SNBF | __SNPT))
goto dumb;
if ((fp->_flags & __SOPT) == 0)
* We get here if we cannot optimise the seek ... just
* do it. Allow the seek function to change fp->_bf._base.
*/
+#endif
dumb:
if (_fflush_r (ptr, fp)
/* Define if ivo supported in streamio. */
#undef _FVWRITE_IN_STREAMIO
+/* Define if fseek functions support seek optimization. */
+#undef _FSEEK_OPTIMIZATION
+
/*
* Iconv encodings enabled ("to" direction)
*/