1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 18:27:35 +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();

View file

@ -20,13 +20,13 @@
#include <LibJS/SafeFunction.h>
#include <setjmp.h>
#ifdef __serenity__
#ifdef AK_OS_SERENITY
# include <serenity.h>
#endif
namespace JS {
#ifdef __serenity__
#ifdef AK_OS_SERENITY
static int gc_perf_string_id;
#endif
@ -36,7 +36,7 @@ static __thread HashMap<FlatPtr*, size_t>* s_custom_ranges_for_conservative_scan
Heap::Heap(VM& vm)
: m_vm(vm)
{
#ifdef __serenity__
#ifdef AK_OS_SERENITY
auto gc_signpost_string = "Garbage collection"sv;
gc_perf_string_id = perf_register_string(gc_signpost_string.characters_without_null_termination(), gc_signpost_string.length());
#endif
@ -91,7 +91,7 @@ void Heap::collect_garbage(CollectionType collection_type, bool print_report)
VERIFY(!m_collecting_garbage);
TemporaryChange change(m_collecting_garbage, true);
#ifdef __serenity__
#ifdef AK_OS_SERENITY
static size_t global_gc_counter = 0;
perf_event(PERF_EVENT_SIGNPOST, gc_perf_string_id, global_gc_counter++);
#endif

View file

@ -20,7 +20,7 @@ namespace JS {
NonnullOwnPtr<HeapBlock> HeapBlock::create_with_cell_size(Heap& heap, size_t cell_size)
{
#ifdef __serenity__
#ifdef AK_OS_SERENITY
char name[64];
snprintf(name, sizeof(name), "LibJS: HeapBlock(%zu)", cell_size);
#else