1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:47:37 +00:00

Everywhere: Replace uses of __serenity__ with AK_OS_SERENITY

Now that we have OS macros for essentially every supported OS, let's try
to use them everywhere.
This commit is contained in:
Andrew Kaster 2022-10-09 15:23:23 -06:00 committed by Linus Groh
parent 896d4e8dc1
commit 828441852f
46 changed files with 118 additions and 113 deletions

View file

@ -21,7 +21,7 @@ BlockAllocator::~BlockAllocator()
{
for (auto* block : m_blocks) {
ASAN_UNPOISON_MEMORY_REGION(block, HeapBlock::block_size);
#ifdef __serenity__
#ifdef AK_OS_SERENITY
if (munmap(block, HeapBlock::block_size) < 0) {
perror("munmap");
VERIFY_NOT_REACHED();
@ -39,7 +39,7 @@ void* BlockAllocator::allocate_block([[maybe_unused]] char const* name)
size_t random_index = get_random_uniform(m_blocks.size());
auto* block = m_blocks.unstable_take(random_index);
ASAN_UNPOISON_MEMORY_REGION(block, HeapBlock::block_size);
#ifdef __serenity__
#ifdef AK_OS_SERENITY
if (set_mmap_name(block, HeapBlock::block_size, name) < 0) {
perror("set_mmap_name");
VERIFY_NOT_REACHED();
@ -48,7 +48,7 @@ void* BlockAllocator::allocate_block([[maybe_unused]] char const* name)
return block;
}
#ifdef __serenity__
#ifdef AK_OS_SERENITY
auto* block = (HeapBlock*)serenity_mmap(nullptr, HeapBlock::block_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_RANDOMIZED | MAP_PRIVATE, 0, 0, HeapBlock::block_size, name);
VERIFY(block != MAP_FAILED);
#else
@ -62,7 +62,7 @@ void BlockAllocator::deallocate_block(void* block)
{
VERIFY(block);
if (m_blocks.size() >= max_cached_blocks) {
#ifdef __serenity__
#ifdef AK_OS_SERENITY
if (munmap(block, HeapBlock::block_size) < 0) {
perror("munmap");
VERIFY_NOT_REACHED();