OSDN Git Service

2007-03-15 Jeff Johnston <jjohnstn@redhat.com>
authorjjohnstn <jjohnstn>
Thu, 15 Mar 2007 21:32:09 +0000 (21:32 +0000)
committerjjohnstn <jjohnstn>
Thu, 15 Mar 2007 21:32:09 +0000 (21:32 +0000)
        * 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.

newlib/ChangeLog
newlib/acconfig.h
newlib/configure
newlib/configure.in
newlib/libc/include/sys/config.h
newlib/libc/stdio/fflush.c
newlib/libc/stdio/local.h
newlib/newlib.hin

index 29b9e0d..62fb9d2 100644 (file)
@@ -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.
index 86f484e..d8b7dc7 100644 (file)
 /* 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
 
index 995358e..e07ca36 100755 (executable)
@@ -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
index 2b8dc7a..378dd94 100644 (file)
@@ -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)
index 58305d4..0ac2b4e 100644 (file)
 #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__ */
index a8ef755..d46b41f 100644 (file)
@@ -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);
index 704b6be..4263a9d 100644 (file)
@@ -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   */
index 2071928..bb09f99 100644 (file)
@@ -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
 /* 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)
  */