diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 4fc9c70259..cb3c3ec8cf 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -837,36 +837,48 @@ insert_user_defined_cmd_args (const char *line)
 {
   /* If we are not in a user-defined command, treat $argc, $arg0, et
      cetera as normal convenience variables.  */
   if (user_args_stack.empty ())
     return line;
 
   const std::unique_ptr<user_args> &args = user_args_stack.back ();
   return args->insert_args (line);
 }
 
+#include <sstream>
+
+namespace patch
+{
+    template < typename T > std::string to_string( const T& n )
+    {
+        std::ostringstream stm ;
+        stm << n ;
+        return stm.str() ;
+    }
+}
+
 /* Insert the user defined arguments stored in user_args into the $arg
    arguments found in line.  */
 
 std::string
 user_args::insert_args (const char *line) const
 {
   std::string new_line;
   const char *p;
 
   while ((p = locate_arg (line)))
     {
       new_line.append (line, p - line);
 
       if (p[4] == 'c')
 	{
-	  new_line += std::to_string (m_args.size ());
+	  new_line += patch::to_string (m_args.size ());
 	  line = p + 5;
 	}
       else
 	{
 	  char *tmp;
 	  unsigned long i;
 
 	  errno = 0;
 	  i = strtoul (p + 4, &tmp, 10);
 	  if ((i == 0 && tmp == p + 4) || errno != 0)
diff --git a/gdb/dwarf-index-write.c b/gdb/dwarf-index-write.c
index 7d59a1ba16..600e522079 100644
--- a/gdb/dwarf-index-write.c
+++ b/gdb/dwarf-index-write.c
@@ -694,21 +694,21 @@ public:
 
   /* Build all the tables.  All symbols must be already inserted.
      This function does not call file_write, caller has to do it
      afterwards.  */
   void build ()
   {
     /* Verify the build method has not be called twice.  */
     gdb_assert (m_abbrev_table.empty ());
     const size_t name_count = m_name_to_value_set.size ();
     m_bucket_table.resize
-      (std::pow (2, std::ceil (std::log2 (name_count * 4 / 3))));
+      (std::pow (2, std::ceil (log2 (name_count * 4 / 3))));
     m_hash_table.reserve (name_count);
     m_name_table_string_offs.reserve (name_count);
     m_name_table_entry_offs.reserve (name_count);
 
     /* Map each hash of symbol to its name and value.  */
     struct hash_it_pair
     {
       uint32_t hash;
       decltype (m_name_to_value_set)::const_iterator it;
     };
diff --git a/gdb/ui-file.h b/gdb/ui-file.h
index 3f6f38a68f..a603b08ee7 100644
--- a/gdb/ui-file.h
+++ b/gdb/ui-file.h
@@ -15,20 +15,24 @@
 
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #ifndef UI_FILE_H
 #define UI_FILE_H
 
 #include <string>
 #include "ui-style.h"
 
+#ifdef putc
+#undef putc
+#endif
+
 /* The abstract ui_file base class.  */
 
 class ui_file
 {
 public:
   ui_file ();
   virtual ~ui_file () = 0;
 
   /* Public non-virtual API.  */
 
diff --git a/gdb/ui-style.c b/gdb/ui-style.c
index 6c3f6e6646..07ae2ea2c1 100644
--- a/gdb/ui-style.c
+++ b/gdb/ui-style.c
@@ -55,45 +55,57 @@ static const uint8_t bright_colors[][3] = {
   { 127, 127, 127 },		/* Black.  */
   { 255, 0, 0 },		/* Red.  */
   { 0, 255, 0 },		/* Green.  */
   { 255, 255, 0 },		/* Yellow.  */
   { 92, 92, 255 },		/* Blue.  */
   { 255, 0, 255 },		/* Magenta.  */
   { 0, 255, 255 },		/* Cyan.  */
   { 255, 255, 255 }		/* White.  */
 };
 
+#include <sstream>
+
+namespace patch
+{
+    template < typename T > std::string to_string( const T& n )
+    {
+        std::ostringstream stm ;
+        stm << n ;
+        return stm.str() ;
+    }
+}
+
 /* See ui-style.h.  */
 
 bool
 ui_file_style::color::append_ansi (bool is_fg, std::string *str) const
 {
   if (m_simple)
     {
       if (m_value >= BLACK && m_value <= WHITE)
-	str->append (std::to_string (m_value + (is_fg ? 30 : 40)));
+	str->append (patch::to_string (m_value + (is_fg ? 30 : 40)));
       else if (m_value > WHITE && m_value <= WHITE + 8)
-	str->append (std::to_string (m_value - WHITE + (is_fg ? 90 : 100)));
+	str->append (patch::to_string (m_value - WHITE + (is_fg ? 90 : 100)));
       else if (m_value != -1)
 	{
 	  str->append (is_fg ? "38;5;" : "48;5;");
-	  str->append (std::to_string (m_value));
+	  str->append (patch::to_string (m_value));
 	}
       else
 	return false;
     }
   else
     {
       str->append (is_fg ? "38;2;" : "48;2;");
-      str->append (std::to_string (m_red)
-		   + ";" + std::to_string (m_green)
-		   + ";" + std::to_string (m_blue));
+      str->append (patch::to_string (m_red)
+		   + ";" + patch::to_string (m_green)
+		   + ";" + patch::to_string (m_blue));
     }
   return true;
 }
 
 /* See ui-style.h.  */
 
 void
 ui_file_style::color::get_rgb (uint8_t *rgb) const
 {
   if (m_simple)
@@ -145,21 +157,21 @@ ui_file_style::to_ansi () const
     {
       if (need_semi)
 	result.push_back (';');
       m_background.append_ansi (false, &result);
       need_semi = true;
     }
   if (m_intensity != NORMAL)
     {
       if (need_semi)
 	result.push_back (';');
-      result.append (std::to_string (m_intensity));
+      result.append (patch::to_string (m_intensity));
       need_semi = true;
     }
   if (m_reverse)
     {
       if (need_semi)
 	result.push_back (';');
       result.push_back ('7');
     }
   result.push_back ('m');
   return result;
diff --git a/libiberty/obstack.c b/libiberty/obstack.c
index 3e1d160700..9ae9b82c0c 100644
--- a/libiberty/obstack.c
+++ b/libiberty/obstack.c
@@ -28,31 +28,32 @@
    obstack.h must be incremented whenever callers compiled using an old
    obstack.h can no longer properly call the functions in this file.  */
 
 /* Comment out all this code if we are using the GNU C Library, and are not
    actually compiling the library itself, and the installed library
    supports the same library interface we do.  This code is part of the GNU
    C Library, but also included in many other GNU distributions.  Compiling
    and linking in this code is a waste when using the GNU C library
    (especially if it is a shared library).  Rather than having every GNU
    program understand 'configure --with-gnu-libc' and omit the object
-   files, it is simpler to just do this in the source for each such file.  */
+   files, it is simpler to just do this in the source for each such file.  
 #if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1
 # include <gnu-versions.h>
 # if (_GNU_OBSTACK_INTERFACE_VERSION == _OBSTACK_INTERFACE_VERSION	      \
       || (_GNU_OBSTACK_INTERFACE_VERSION == 1				      \
           && _OBSTACK_INTERFACE_VERSION == 2				      \
           && defined SIZEOF_INT && defined SIZEOF_SIZE_T		      \
           && SIZEOF_INT == SIZEOF_SIZE_T))
 #  define _OBSTACK_ELIDE_CODE
 # endif
 #endif
+*/
 
 #ifndef _OBSTACK_ELIDE_CODE
 /* If GCC, or if an oddball (testing?) host that #defines __alignof__,
    use the already-supplied __alignof__.  Otherwise, this must be Gnulib
    (as glibc assumes GCC); defer to Gnulib's alignof_type.  */
 # if !defined __GNUC__ && !defined __IBM__ALIGNOF__ && !defined __alignof__
 #  if defined __cplusplus
 template <class type> struct alignof_helper { char __slot1; type __slot2; };
 #   define __alignof__(type) offsetof (alignof_helper<type>, __slot2)
 #  else
