summaryrefslogtreecommitdiff
path: root/libstdc++-v3/libsupc++/eh_alloc.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/libsupc++/eh_alloc.cc')
-rw-r--r--libstdc++-v3/libsupc++/eh_alloc.cc21
1 files changed, 17 insertions, 4 deletions
diff --git a/libstdc++-v3/libsupc++/eh_alloc.cc b/libstdc++-v3/libsupc++/eh_alloc.cc
index ab285fd6e97..dbf007e09d8 100644
--- a/libstdc++-v3/libsupc++/eh_alloc.cc
+++ b/libstdc++-v3/libsupc++/eh_alloc.cc
@@ -31,15 +31,28 @@
// for cross-architecture compatibility are noted with "@@@".
#include <cstdlib>
+#if _GLIBCXX_HOSTED
#include <cstring>
+#endif
#include <climits>
#include <exception>
#include "unwind-cxx.h"
#include "bits/c++config.h"
#include "bits/gthr.h"
-using namespace __cxxabiv1;
+#if _GLIBCXX_HOSTED
+using std::free;
+using std::malloc;
+using std::memcpy;
+#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 *);
+extern "C" int memset (void *, int, std::size_t);
+#endif
+using namespace __cxxabiv1;
// ??? How to control these parameters.
@@ -99,7 +112,7 @@ __cxa_allocate_exception(std::size_t thrown_size) throw()
void *ret;
thrown_size += sizeof (__cxa_exception);
- ret = std::malloc (thrown_size);
+ ret = malloc (thrown_size);
if (! ret)
{
@@ -134,7 +147,7 @@ __cxa_allocate_exception(std::size_t thrown_size) throw()
std::terminate ();
}
- std::memset (ret, 0, sizeof (__cxa_exception));
+ memset (ret, 0, sizeof (__cxa_exception));
return (void *)((char *)ret + sizeof (__cxa_exception));
}
@@ -159,5 +172,5 @@ __cxa_free_exception(void *vptr) throw()
#endif
}
else
- std::free (ptr - sizeof (__cxa_exception));
+ free (ptr - sizeof (__cxa_exception));
}