General aarch64 improvements & Apple Silicon support (#1255)

This commit is contained in:
Exverge 2025-06-18 04:36:05 -04:00 committed by GitHub
parent c8ffff8f41
commit 00ff5549d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 405 additions and 32 deletions

View file

@ -15,7 +15,12 @@ Fiber::Fiber(void(*FiberEntryPoint)(void* userParam), void* userParam, void* pri
ctx->uc_stack.ss_sp = m_stackPtr;
ctx->uc_stack.ss_size = stackSize;
ctx->uc_link = &ctx[0];
#ifdef __arm64__
// https://www.man7.org/linux/man-pages/man3/makecontext.3.html#NOTES
makecontext(ctx, (void(*)())FiberEntryPoint, 2, (uint64) userParam >> 32, userParam);
#else
makecontext(ctx, (void(*)())FiberEntryPoint, 1, userParam);
#endif
this->m_implData = (void*)ctx;
}

View file

@ -45,7 +45,11 @@ namespace MemMapper
void* r;
if(fromReservation)
{
if( mprotect(baseAddr, size, GetProt(permissionFlags)) == 0 )
uint64 page_size = sysconf(_SC_PAGESIZE);
void* page = baseAddr;
if ( (uint64) baseAddr % page_size != 0 )
page = (void*) ((uint64)baseAddr & ~(page_size - 1));
if( mprotect(page, size, GetProt(permissionFlags)) == 0 )
r = baseAddr;
else
r = nullptr;

View file

@ -27,6 +27,8 @@ uint64 HighResolutionTimer::m_freq = []() -> uint64 {
LARGE_INTEGER freq;
QueryPerformanceFrequency(&freq);
return (uint64)(freq.QuadPart);
#elif BOOST_OS_MACOS
return 1000000000;
#else
timespec pc;
clock_getres(CLOCK_MONOTONIC_RAW, &pc);