Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2007-03-16 00:32:13 +0300
committerJeff Johnston <jjohnstn@redhat.com>2007-03-16 00:32:13 +0300
commit826b5591dd604ef68abadff7c8cb7c19e221b9af (patch)
tree1d1cd77cbe1ec91d5bc33e3879db3efdddbfc8c4
parent14ba5e14d9226cb4dd1b2a72781ee02e9f2bf8a2 (diff)
2007-03-15 Jeff Johnston <jjohnstn@redhat.com>
* configure.in: Add new --enable-newlib-reent-small option. * configure: Regenerated. * acconfig.h: Add _WANT_REENT_SMALL. * newlib.hin: Regenerated minus PACKAGE macros to add _WANT_REENT_SMALL macro. * libc/include/sys/config.h[_WANT_REENT_SMALL]: Set _REENT_SMALL if not already set. * libc/stdio/fflush.c[_REENT_SMALL]: Return immediately if there is no buffer. * libc/stdio/local.h[_REENT_SMALL]: Fix CHECK_INIT macro to use reentrant pointer passed in when resetting the file pointer to one of the std streams.
-rw-r--r--newlib/ChangeLog15
-rw-r--r--newlib/acconfig.h4
-rwxr-xr-xnewlib/configure23
-rw-r--r--newlib/configure.in13
-rw-r--r--newlib/libc/include/sys/config.h8
-rw-r--r--newlib/libc/stdio/fflush.c16
-rw-r--r--newlib/libc/stdio/local.h6
-rw-r--r--newlib/newlib.hin7
8 files changed, 87 insertions, 5 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index 29b9e0de8..62fb9d22d 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,18 @@
+2007-03-15 Jeff Johnston <jjohnstn@redhat.com>
+
+ * configure.in: Add new --enable-newlib-reent-small option.
+ * configure: Regenerated.
+ * acconfig.h: Add _WANT_REENT_SMALL.
+ * newlib.hin: Regenerated minus PACKAGE macros to add
+ _WANT_REENT_SMALL macro.
+ * libc/include/sys/config.h[_WANT_REENT_SMALL]: Set _REENT_SMALL
+ if not already set.
+ * libc/stdio/fflush.c[_REENT_SMALL]: Return immediately if
+ there is no buffer.
+ * libc/stdio/local.h[_REENT_SMALL]: Fix CHECK_INIT macro to
+ use reentrant pointer passed in when resetting the file
+ pointer to one of the std streams.
+
2007-03-15 Eric Blake <ebb9@byu.net>
* libc/stdio/local.h (cantwrite, FREEUB, FREELB): Make reentrant.
diff --git a/newlib/acconfig.h b/newlib/acconfig.h
index 86f484ec4..d8b7dc774 100644
--- a/newlib/acconfig.h
+++ b/newlib/acconfig.h
@@ -18,6 +18,10 @@
/* Positional argument support in printf functions enabled. */
#undef _WANT_IO_POS_ARGS
+/* Optional reentrant struct support. Used mostly on platforms with
+ very restricted storage. */
+#undef _WANT_REENT_SMALL
+
/* Multibyte supported */
#undef _MB_CAPABLE
diff --git a/newlib/configure b/newlib/configure
index 995358ed9..e07ca3611 100755
--- a/newlib/configure
+++ b/newlib/configure
@@ -831,6 +831,7 @@ Optional Features:
--enable-newlib-iconv-to-encodings enable specific comma-separated list of \"to\" iconv encodings to be built-in
--enable-newlib-iconv-external-ccs enable capabilities to load external CCS files for iconv
--disable-newlib-atexit-alloc disable dynamic allocation of atexit entries
+ --enable-newlib-reent-small enable small reentrant struct support
--enable-multilib build many library versions (default)
--enable-target-optspace optimize for space
--enable-malloc-debugging indicate malloc debugging requested
@@ -1464,6 +1465,19 @@ echo "$as_me: error: bad value ${enableval} for newlib-atexit-dynamic-alloc opti
else
newlib_atexit_dynamic_alloc=${newlib_atexit_dynamic_alloc}
fi;
+# Check whether --enable-newlib-reent-small or --disable-newlib-reent-small was given.
+if test "${enable_newlib_reent_small+set}" = set; then
+ enableval="$enable_newlib_reent_small"
+ case "${enableval}" in
+ yes) newlib_reent_small=yes;;
+ no) newlib_reent_small=no ;;
+ *) { { echo "$as_me:$LINENO: error: bad value ${enableval} for newlib-reent-small option" >&5
+echo "$as_me: error: bad value ${enableval} for newlib-reent-small option" >&2;}
+ { (exit 1); exit 1; }; } ;;
+ esac
+else
+ newlib_reent_small=
+fi;
# Make sure we can run config.sub.
$ac_config_sub sun4 >/dev/null 2>&1 ||
@@ -4764,7 +4778,7 @@ test x"$pic_mode" = xno && libtool_flags="$libtool_flags --prefer-non-pic"
case $host in
*-*-irix6*)
# Find out which ABI we are using.
- echo '#line 4767 "configure"' > conftest.$ac_ext
+ echo '#line 4781 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -5204,6 +5218,13 @@ _ACEOF
fi
+if test "${newlib_reent_small}" = "yes"; then
+cat >>confdefs.h <<_ACEOF
+#define _WANT_REENT_SMALL 1
+_ACEOF
+
+fi
+
if test "${newlib_mb}" = "yes"; then
cat >>confdefs.h <<_ACEOF
#define _MB_CAPABLE 1
diff --git a/newlib/configure.in b/newlib/configure.in
index 2b8dc7a9b..378dd942c 100644
--- a/newlib/configure.in
+++ b/newlib/configure.in
@@ -97,6 +97,15 @@ AC_ARG_ENABLE(newlib-atexit-dynamic-alloc,
esac
fi], [newlib_atexit_dynamic_alloc=${newlib_atexit_dynamic_alloc}])dnl
+dnl Support --enable-newlib-reent-small
+AC_ARG_ENABLE(newlib-reent-small,
+[ --enable-newlib-reent-small enable small reentrant struct support],
+[case "${enableval}" in
+ yes) newlib_reent_small=yes;;
+ no) newlib_reent_small=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for newlib-reent-small option) ;;
+ esac], [newlib_reent_small=])dnl
+
NEWLIB_CONFIGURE(.)
dnl We have to enable libtool after NEWLIB_CONFIGURE because if we try and
@@ -232,6 +241,10 @@ if test "${newlib_io_pos_args}" = "yes"; then
AC_DEFINE_UNQUOTED(_WANT_IO_POS_ARGS)
fi
+if test "${newlib_reent_small}" = "yes"; then
+AC_DEFINE_UNQUOTED(_WANT_REENT_SMALL)
+fi
+
if test "${newlib_mb}" = "yes"; then
AC_DEFINE_UNQUOTED(_MB_CAPABLE)
AC_DEFINE_UNQUOTED(_MB_LEN_MAX,8)
diff --git a/newlib/libc/include/sys/config.h b/newlib/libc/include/sys/config.h
index 58305d4a8..0ac2b4ec8 100644
--- a/newlib/libc/include/sys/config.h
+++ b/newlib/libc/include/sys/config.h
@@ -202,4 +202,12 @@
#endif
#endif
+/* See if small reent asked for at configuration time and
+ is not chosen by the platform by default. */
+#ifdef _WANT_REENT_SMALL
+#ifndef _REENT_SMALL
+#define _REENT_SMALL
+#endif
+#endif
+
#endif /* __SYS_CONFIG_H__ */
diff --git a/newlib/libc/stdio/fflush.c b/newlib/libc/stdio/fflush.c
index a8ef755c2..d46b41f94 100644
--- a/newlib/libc/stdio/fflush.c
+++ b/newlib/libc/stdio/fflush.c
@@ -67,6 +67,22 @@ _DEFUN(fflush, (fp),
if (fp == NULL)
return _fwalk (_GLOBAL_REENT, fflush);
+#ifdef _REENT_SMALL
+ /* For REENT_SMALL platforms, it is possible we are being
+ called for the first time on a std stream. This std
+ stream can belong to a reentrant struct that is not
+ _REENT. If CHECK_INIT gets called below based on _REENT,
+ we will end up changing said file pointers to the equivalent
+ std stream off of _REENT. This causes unexpected behavior if
+ there is any data to flush on the _REENT std stream. There
+ are two alternatives to fix this: 1) make a reentrant fflush
+ or 2) simply recognize that this file has nothing to flush
+ and return immediately before performing a CHECK_INIT. Choice
+ 2 is implemented here due to its simplicity. */
+ if (fp->_bf._base == NULL)
+ return 0;
+#endif /* _REENT_SMALL */
+
CHECK_INIT (_REENT, fp);
_flockfile (fp);
diff --git a/newlib/libc/stdio/local.h b/newlib/libc/stdio/local.h
index 704b6be03..4263a9de6 100644
--- a/newlib/libc/stdio/local.h
+++ b/newlib/libc/stdio/local.h
@@ -55,11 +55,11 @@ struct _glue * _EXFUN(__sfmoreglue,(struct _reent *,int n));
if ((ptr) && !(ptr)->__sdidinit) \
__sinit (ptr); \
if ((fp) == (FILE *)&__sf_fake_stdin) \
- (fp) = stdin; \
+ (fp) = _stdin_r(ptr); \
else if ((fp) == (FILE *)&__sf_fake_stdout) \
- (fp) = stdout; \
+ (fp) = _stdout_r(ptr); \
else if ((fp) == (FILE *)&__sf_fake_stderr) \
- (fp) = stderr; \
+ (fp) = _stderr_r(ptr); \
} \
while (0)
#else /* !_REENT_SMALL */
diff --git a/newlib/newlib.hin b/newlib/newlib.hin
index 207192897..bb09f9970 100644
--- a/newlib/newlib.hin
+++ b/newlib/newlib.hin
@@ -1,4 +1,4 @@
-/* newlib.hin. Generated automatically from configure.in by autoheader. */
+/* newlib.hin. Generated from configure.in by autoheader. */
#ifndef __NEWLIB_H__
#define __NEWLIB_H__ 1
@@ -18,6 +18,10 @@
/* Positional argument support in printf functions enabled. */
#undef _WANT_IO_POS_ARGS
+/* Optional reentrant struct support. Used mostly on platforms with
+ very restricted storage. */
+#undef _WANT_REENT_SMALL
+
/* Multibyte supported */
#undef _MB_CAPABLE
@@ -40,6 +44,7 @@
/* Define if the compiler supports aliasing an array to an address. */
#undef _HAVE_ARRAY_ALIASING
+
/*
* Iconv encodings enabled ("to" direction)
*/