Some more stdlib (array and vector, untested so far).

This commit is contained in:
2024-01-12 00:13:45 +01:00
parent 164f05bd59
commit ff3214fa5a
23 changed files with 577 additions and 9 deletions

17
stdlib/src/exception.cpp Normal file
View File

@@ -0,0 +1,17 @@
#include <exception>
namespace std
{
const char* exception::what() const noexcept
{
return "";
}
}
#if !defined(__cpp_exceptions)
namespace ba::impl
{
ExceptionAbortHelper gAbortHelper;
}
#endif

50
stdlib/src/new.cpp Normal file
View File

@@ -0,0 +1,50 @@
#include <new>
#include <cstdlib>
namespace std
{
const char* bad_alloc::what() const noexcept
{
return "bad_alloc";
}
}
void* operator new(size_t count)
{
if (void* ptr = malloc(count); ptr != nullptr)
{
return ptr;
}
__ba_throw std::bad_alloc();
}
void operator delete(void* data) noexcept
{
std::free(data);
}
void* operator new[](size_t count)
{
if (void* ptr = malloc(count); ptr != nullptr)
{
return ptr;
}
__ba_throw std::bad_alloc();
}
void operator delete[](void* data) noexcept
{
std::free(data);
}
void operator delete(void* data, size_t /* size */) noexcept
{
std::free(data);
}
void operator delete[](void* data, size_t /* size */) noexcept
{
std::free(data);
}