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.
This commit is contained in:
Jeff Johnston 2013-04-10 18:47:46 +00:00
parent b49dae4a44
commit 602cec7f1e
9 changed files with 70 additions and 2 deletions

View File

@ -1,3 +1,14 @@
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.

View File

@ -58,6 +58,9 @@
/* 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)

26
newlib/configure vendored
View File

@ -790,6 +790,7 @@ enable_newlib_iconv_external_ccs
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
@ -1454,6 +1455,7 @@ Optional Features:
--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
@ -2366,6 +2368,19 @@ else
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 ||
@ -11666,7 +11681,7 @@ else
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
@ -11772,7 +11787,7 @@ else
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
@ -12254,6 +12269,13 @@ _ACEOF
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" \

View File

@ -135,6 +135,17 @@ AC_ARG_ENABLE(newlib-fvwrite-in-streamio,
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
@ -327,6 +338,10 @@ fi
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

View File

@ -80,10 +80,12 @@ _DEFUN(__sflush_r, (ptr, fp),
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
@ -152,7 +154,9 @@ _DEFUN(__sflush_r, (ptr, fp),
{
/* 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))

View File

@ -219,6 +219,8 @@ _DEFUN(_fseeko_r, (ptr, fp, offset, whence),
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)
@ -350,6 +352,7 @@ _DEFUN(_fseeko_r, (ptr, fp, offset, whence),
* 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)

View File

@ -65,8 +65,10 @@ _DEFUN(__smakebuf_r, (ptr, fp),
size = _DEFAULT_ASPRINTF_BUFSIZE;
else
size = BUFSIZ;
#ifdef _FSEEK_OPTIMIZATION
/* do not try to optimise fseek() */
fp->_flags |= __SNPT;
#endif
}
else
{
@ -76,6 +78,7 @@ _DEFUN(__smakebuf_r, (ptr, fp),
#else
size = BUFSIZ;
#endif
#ifdef _FSEEK_OPTIMIZATION
/*
* Optimize fseek() only if it is a regular file.
* (The test for __sseek is mainly paranoia.)
@ -91,6 +94,7 @@ _DEFUN(__smakebuf_r, (ptr, fp),
}
else
fp->_flags |= __SNPT;
#endif
}
if ((p = _malloc_r (ptr, size)) == NULL)
{

View File

@ -209,6 +209,8 @@ _DEFUN (_fseeko64_r, (ptr, fp, offset, whence),
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)
@ -330,6 +332,7 @@ _DEFUN (_fseeko64_r, (ptr, fp, offset, whence),
* 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)

View File

@ -61,6 +61,9 @@
/* 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)
*/