// 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.
void *ret;
thrown_size += sizeof (__cxa_exception);
- ret = std::malloc (thrown_size);
+ ret = malloc (thrown_size);
if (! ret)
{
std::terminate ();
}
- std::memset (ret, 0, sizeof (__cxa_exception));
+ memset (ret, 0, sizeof (__cxa_exception));
return (void *)((char *)ret + sizeof (__cxa_exception));
}
#endif
}
else
- std::free (ptr - sizeof (__cxa_exception));
+ free (ptr - sizeof (__cxa_exception));
}