---
 libstdc++-v3/libsupc++/atexit_thread.cc | 12 ++++++++++++
 libstdc++-v3/libsupc++/unwind-cxx.h     |  8 ++++++++
 2 files changed, 20 insertions(+)

diff --git a/libstdc++-v3/libsupc++/atexit_thread.cc 
b/libstdc++-v3/libsupc++/atexit_thread.cc
index 58e611a3b5f..18279c302f7 100644
--- a/libstdc++-v3/libsupc++/atexit_thread.cc
+++ b/libstdc++-v3/libsupc++/atexit_thread.cc
@@ -44,8 +44,20 @@ __cxa_thread_atexit (void (_GLIBCXX_CDTOR_CALLABI 
*dtor)(void *),
 #else // __USING_MCFGTHREAD__
 
 #ifdef _GLIBCXX_THREAD_ATEXIT_WIN32
+
+#if _GLIBCXX_HOSTED
+using std::free;
+using std::malloc;
+#else
+// In a freestanding environment, these functions may not be available
+// -- but for now, we assume that they are.
+extern "C" void *malloc (std::size_t);
+extern "C" void free(void *);
+#endif
+
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
+
 #endif
 
 // Simplify it a little for this file.
diff --git a/libstdc++-v3/libsupc++/unwind-cxx.h 
b/libstdc++-v3/libsupc++/unwind-cxx.h
index f39ea86346b..735ff0b924e 100644
--- a/libstdc++-v3/libsupc++/unwind-cxx.h
+++ b/libstdc++-v3/libsupc++/unwind-cxx.h
@@ -30,6 +30,14 @@
 
 // Level 2: C++ ABI
 
+#if !_GLIBCXX_HOSTED
+#include <cstdint>
+// In a freestanding environment, these functions may not be available
+// -- but for now, we assume that they are.
+extern "C" void *malloc (std::size_t);
+extern "C" void free(void*);
+#endif
+
 #include <typeinfo>
 #include <exception>
 #include <cstddef>
-- 
2.50.1

Reply via email to