Skip to content

Remove undefined behaviour and make compatible with apple/clang #5

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Naxaes
Copy link

@Naxaes Naxaes commented Jun 11, 2025

I've made two separate commits which can be cherry-picked.

Remove non-ASM statement in naked function

Non-ASM statements in naked functions are undefined behaviour, only basic ASM statements can safely be included in naked functions. Clang won't even compile (void)rsp; statements, so I replaced them with __attribite__((unused)).

https://stackoverflow.com/a/47343399

Add missing names for Apple and clang

Apple OSes doesn't have MAP_STACK or MAP_GROWSDOWN, so I replaced them with 0. They seem to be missing the threads.h header and asm keyword, so made simple defines for them that works for both gcc and clang.

Also, clang (and probably other compilers) prepend underscore to their labels.

Naxaes added 2 commits June 11, 2025 15:48
Non-ASM statements are undefined behaviour.
Apple OSes doesn't have MAP_STACK or MAP_GROWSDOWN.

Clang (and probably other compilers) prepend underscore to their labels.
@Naxaes
Copy link
Author

Naxaes commented Jun 11, 2025

For this to compile on Apple, you need to have Rosetta (X86_64 emulation) that's available on Apple chips, and compile with -arch x86_64.

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.

1 participant