mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-21 18:37:58 +03:00
e904f193c1
With a bunch of LibC work to support the feature. LibC now initializes AK::StringImpl by default. It's now fine to use AK in LibC/Userland! :^)
50 lines
703 B
C++
50 lines
703 B
C++
#include "stdlib.h"
|
|
#include "mman.h"
|
|
#include <Kernel/Syscall.h>
|
|
#include <AK/Assertions.h>
|
|
|
|
extern "C" {
|
|
|
|
void* malloc(size_t size)
|
|
{
|
|
if (size > 4096) {
|
|
volatile char* crashme = (char*)0xc007d00d;
|
|
*crashme = 0;
|
|
}
|
|
void* ptr = mmap(nullptr, 4096);
|
|
return ptr;
|
|
}
|
|
|
|
void free(void* ptr)
|
|
{
|
|
if (!ptr)
|
|
return;
|
|
munmap(ptr, 4096);
|
|
}
|
|
|
|
void* calloc(size_t nmemb, size_t)
|
|
{
|
|
ASSERT_NOT_REACHED();
|
|
return nullptr;
|
|
}
|
|
|
|
void* realloc(void *ptr, size_t)
|
|
{
|
|
ASSERT_NOT_REACHED();
|
|
return nullptr;
|
|
}
|
|
|
|
void exit(int status)
|
|
{
|
|
Syscall::invoke(Syscall::PosixExit, (dword)status);
|
|
}
|
|
|
|
void abort()
|
|
{
|
|
// FIXME: Implement proper abort().
|
|
exit(253);
|
|
}
|
|
|
|
}
|
|
|