Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Mac OS < 10.15 #889

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aleph1
Copy link

@aleph1 aleph1 commented Feb 19, 2025

When working with the Box2D source in Xcode there is a single warning for Box2D in src/core.c the line void* ptr = aligned_alloc( B2_ALIGNMENT, size32 );. Xcode warns that aligned_alloc was only introduced in Mac OS version 10.15. I've modified the file to include some code that should allow Box2D to run on older versions of Mac OS, but I don't have 10.14 or a previous version installed to test. The modified code still works when built on a newer version of Mac OS.

I will aim to install a VM running 10.14 and test this at some point, but it might take a while.

Added fallback for unsupported aligned_alloc Mac OS < 10.15 so it uses posix_memalign as per the current Android implementation.
@aleph1
Copy link
Author

aleph1 commented Feb 19, 2025

It might also be worth considering using just __builtin_available:

...
#elif defined ( B2_PLATFORM_MACOS )
void* ptr = __builtin_available(macOS 10.15, *) ? aligned_alloc( B2_ALIGNMENT, size32 ) : aligned_alloc_macos_lt_10_15( B2_ALIGNMENT, size32 );
#else
...

@erincatto
Copy link
Owner

If this is important to support I would add padding like SDL does and not use aligned allocators. However, I'm not supporting x86 macs either. So I'm not sure if this is worthwhile.

@aleph1
Copy link
Author

aleph1 commented Feb 19, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants