Closed triplef closed 5 years ago
Looks like this will need some more work. I found that memalign() is not available e.g. on macOS using the Xcode toolchain, so using posix_memalign() is probably the better choice.
memalign is a glibcism, but posix_memalign works pretty much everywhere (except Windows, but we're already special-casing Windows here). Happy to merge a PR that uses posix_memalign.
Thanks. I’ve updated the patch to use posix_memalign with getpagesize(). I think that should be the equivalent of valloc?
I ended up inlining the VirtualAlloc call on Windows, let me know if you prefer doing it another way.
valloc() no longer exists in some toolchains like Android arm64 (see here), but using
memalign(getpagesize(), len)
should be identical.Caveat: I haven’t been able to verify whether support for memalign() and getpagesize() is universal.