Common: Fix slow emulator startup on M1s

This commit is contained in:
TellowKrinkle 2022-11-24 20:43:54 -06:00 committed by refractionpcsx2
parent 50f90aee79
commit ee451fe345
1 changed files with 5 additions and 0 deletions

View File

@ -28,6 +28,11 @@ void* _aligned_malloc(size_t size, size_t align)
#if defined(__USE_ISOC11) && !defined(ASAN_WORKAROUND) // not supported yet on gcc 4.9
return aligned_alloc(align, size);
#else
#ifdef __APPLE__
// MacOS has a bug where posix_memalign is ridiculously slow on unaligned sizes
// This especially bad on M1s for some reason
size = (size + align - 1) & ~(align - 1);
#endif
void* result = 0;
posix_memalign(&result, align, size);
return result;