* acconfig.h (_UNBUF_STREAM_OPT): Undefine.

* newlib.hin (_UNBUF_STREAM_OPT): Undefine.
	* configure.in (--enable-newlib-unbuf-stream-opt): New option.
	* configure: Regenerate.
	* libc/stdio/vfprintf.c (_VFPRINTF_R): Don't do optimization on
	unbuffered stream files.
	* libc/stdio/vfwprintf.c (_VFWPRINTF_R): Likewise.
	* README: Add description about the option.
	* newlib.hin (_UNBUF_STREAM_OPT): Undefine.
	* configure.in (--enable-newlib-unbuf-stream-opt): New option.
	* configure: Regenerate.
	* libc/stdio/vfprintf.c (_VFPRINTF_R): Don't do optimization on
	unbuffered stream files.
	* libc/stdio/vfwprintf.c (_VFWPRINTF_R): Likewise.
	* README: Add description about the option.
This commit is contained in:
Corinna Vinschen 2013-06-19 15:58:50 +00:00
parent 04f8f69cb7
commit 82c19d335a
8 changed files with 77 additions and 1 deletions

View File

@ -1,3 +1,21 @@
2013-06-19 Bin Cheng <bin.cheng@arm.com>
* acconfig.h (_UNBUF_STREAM_OPT): Undefine.
* newlib.hin (_UNBUF_STREAM_OPT): Undefine.
* configure.in (--enable-newlib-unbuf-stream-opt): New option.
* configure: Regenerate.
* libc/stdio/vfprintf.c (_VFPRINTF_R): Don't do optimization on
unbuffered stream files.
* libc/stdio/vfwprintf.c (_VFWPRINTF_R): Likewise.
* README: Add description about the option.
* newlib.hin (_UNBUF_STREAM_OPT): Undefine.
* configure.in (--enable-newlib-unbuf-stream-opt): New option.
* configure: Regenerate.
* libc/stdio/vfprintf.c (_VFPRINTF_R): Don't do optimization on
unbuffered stream files.
* libc/stdio/vfwprintf.c (_VFWPRINTF_R): Likewise.
* README: Add description about the option.
2013-06-19 Terraneo Federico <fede.tft@hotmail.it>
* libc/posix/readdir_r.c: Fix potential read past dirp->dd_buf.

View File

@ -321,6 +321,13 @@ One feature can be enabled by specifying `--enable-FEATURE=yes' or
support `--enable-malloc-debugging' any more.
Disabled by default.
`--disable-newlib-unbuf-stream-opt'
NEWLIB does optimization when `fprintf to write only unbuffered unix
file'. It creates a temorary buffer to do the optimization that
increases stack consumption by about `BUFSIZ' bytes. This option
disables the optimization and saves size of text and stack.
Enabled by default.
`--enable-multilib'
Build many library versions.
Enabled by default.

View File

@ -64,6 +64,9 @@
/* Define if wide char orientation is supported. */
#undef _WIDE_ORIENT
/* Define if unbuffered stream file optimization is supported. */
#undef _UNBUF_STREAM_OPT
@BOTTOM@
/*
* Iconv encodings enabled ("to" direction)

24
newlib/configure vendored
View File

@ -793,6 +793,7 @@ enable_newlib_fvwrite_in_streamio
enable_newlib_fseek_optimization
enable_newlib_wide_orient
enable_newlib_nano_malloc
enable_newlib_unbuf_stream_opt
enable_multilib
enable_target_optspace
enable_malloc_debugging
@ -1460,6 +1461,7 @@ Optional Features:
--disable-newlib-fseek-optimization disable fseek optimization
--disable-newlib-wide-orient Turn off wide orientation in streamio
--enable-newlib-nano-malloc use small-footprint nano-malloc implementation
--disable-newlib-unbuf-stream-opt disable unbuffered stream optimization in streamio
--enable-multilib build many library versions (default)
--enable-target-optspace optimize for space
--enable-malloc-debugging indicate malloc debugging requested
@ -2410,6 +2412,19 @@ else
newlib_nano_malloc=no
fi
# Check whether --enable-newlib-unbuf-stream-opt was given.
if test "${enable_newlib_unbuf_stream_opt+set}" = set; then :
enableval=$enable_newlib_unbuf_stream_opt; if test "${newlib_unbuf_stream_opt+set}" != set; then
case "${enableval}" in
yes) newlib_unbuf_stream_opt=yes ;;
no) newlib_unbuf_stream_opt=no ;;
*) as_fn_error $? "bad value ${enableval} for newlib-unbuf-stream-opt option" "$LINENO" 5 ;;
esac
fi
else
newlib_unbuf_stream_opt=yes
fi
# Make sure we can run config.sub.
$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
@ -12314,7 +12329,14 @@ fi
if test "${newlib_nano_malloc}" = "yes"; then
cat >>confdefs.h <<_ACEOF
#define NEWLIB_NANO_MALLOC 1
#define _NANO_MALLOC 1
_ACEOF
fi
if test "${newlib_unbuf_stream_opt}" = "yes"; then
cat >>confdefs.h <<_ACEOF
#define _UNBUF_STREAM_OPT 1
_ACEOF
fi

View File

@ -170,6 +170,17 @@ AC_ARG_ENABLE(newlib-nano-malloc,
esac
fi], [newlib_nano_malloc=no])dnl
dnl Support --disable-newlib-unbuf-stream-opt
AC_ARG_ENABLE(newlib-unbuf-stream-opt,
[ --disable-newlib-unbuf-stream-opt disable unbuffered stream optimization in streamio],
[if test "${newlib_unbuf_stream_opt+set}" != set; then
case "${enableval}" in
yes) newlib_unbuf_stream_opt=yes ;;
no) newlib_unbuf_stream_opt=no ;;
*) AC_MSG_ERROR(bad value ${enableval} for newlib-unbuf-stream-opt option) ;;
esac
fi], [newlib_unbuf_stream_opt=yes])dnl
NEWLIB_CONFIGURE(.)
dnl We have to enable libtool after NEWLIB_CONFIGURE because if we try and
@ -375,6 +386,10 @@ if test "${newlib_nano_malloc}" = "yes"; then
AC_DEFINE_UNQUOTED(_NANO_MALLOC)
fi
if test "${newlib_unbuf_stream_opt}" = "yes"; then
AC_DEFINE_UNQUOTED(_UNBUF_STREAM_OPT)
fi
dnl
dnl Parse --enable-newlib-iconv-encodings option argument
dnl

View File

@ -447,6 +447,7 @@ int __sfputs_r (struct _reent *, FILE *, _CONST char *buf, size_t);
int __sprint_r (struct _reent *, FILE *, register struct __suio *);
#endif /* !INTEGER_ONLY */
#ifdef _UNBUF_STREAM_OPT
/*
* Helper function for `fprintf to unbuffered unix file': creates a
* temporary buffer. We only work on write-only files; this avoids
@ -492,6 +493,7 @@ _DEFUN(__sbprintf, (rptr, fp, fmt, ap),
#endif
return (ret);
}
#endif /* _UNBUF_STREAM_OPT */
#endif /* !STRING_ONLY */
@ -865,12 +867,14 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap),
return (EOF);
}
#ifdef _UNBUF_STREAM_OPT
/* optimise fprintf(stderr) (and other unbuffered Unix files) */
if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) &&
fp->_file >= 0) {
_newlib_flockfile_exit (fp);
return (__sbprintf (data, fp, fmt0, ap));
}
#endif
#else /* STRING_ONLY */
/* Create initial buffer if we are called by asprintf family. */
if (fp->_flags & __SMBF && !fp->_bf._base)

View File

@ -166,6 +166,7 @@ int _EXFUN(__SPRINT, (struct _reent *, FILE *, register struct __suio *));
int _EXFUN(__SPRINT, (struct _reent *, FILE *, _CONST char *, size_t));
#endif
#ifndef STRING_ONLY
#ifdef _UNBUF_STREAM_OPT
/*
* Helper function for `fprintf to unbuffered unix file': creates a
* temporary buffer. We only work on write-only files; this avoids
@ -209,6 +210,7 @@ _DEFUN(__sbwprintf, (rptr, fp, fmt, ap),
#endif
return (ret);
}
#endif /* _UNBUF_STREAM_OPT */
#endif /* !STRING_ONLY */
@ -599,12 +601,14 @@ _DEFUN(_VFWPRINTF_R, (data, fp, fmt0, ap),
return (EOF);
}
#ifdef _UNBUF_STREAM_OPT
/* optimise fwprintf(stderr) (and other unbuffered Unix files) */
if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) &&
fp->_file >= 0) {
_newlib_flockfile_exit (fp);
return (__sbwprintf (data, fp, fmt0, ap));
}
#endif
#else /* STRING_ONLY */
/* Create initial buffer if we are called by asprintf family. */
if (fp->_flags & __SMBF && !fp->_bf._base)

View File

@ -67,6 +67,9 @@
/* Define if wide char orientation is supported. */
#undef _WIDE_ORIENT
/* Define if unbuffered stream file optimization is supported. */
#undef _UNBUF_STREAM_OPT
/*
* Iconv encodings enabled ("to" direction)
*/