gnustep / libobjc2

Objective-C runtime library intended for use with Clang.
http://www.gnustep.org/
MIT License
434 stars 118 forks source link

Replace valloc() with memalign() to support e.g. Android arm64 #91

Closed triplef closed 5 years ago

triplef commented 5 years ago

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.

triplef commented 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.

davidchisnall commented 5 years ago

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.

triplef commented 5 years ago

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.