-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Allow specifying function alignment #75072
Comments
For context, how is this requirement addressed by C toolchains? |
Using https://c.godbolt.org/z/E7ETx8 to verify, it looks like both GCC and Clang support using |
I believe you would need to use assembly for interrupt handlers because naked functions don't work as intended anyway. |
I'm on the exact same situation as @repnop, with the exact same context. |
If this is something that should be part of the language, I would gladly try to implement it |
I'd also find this quite helpful for some low-level bit twiddling I'm doing. |
@Skallwar oh, somehow I missed the notification from this issue. yeah, currently I'm (ab)using that in a Opened a PR so we'll see where this goes :) |
The tracking issue for |
I've been recently writing a kernel for the RISC-V architecture, using strictly as much Rust as I can get away with and during which I've run into the need to have certain functions aligned to specific byte alignments (ex. any function placed in
mtvec
MUST be 4 byte aligned), and while I can seemingly accomplish this usingasm!(".align <alignment>")
I think it would make sense for that to be an attribute of the function itself, whether it be limited toextern "C"
fns or valid on all ABIs. Example of what I am asking for:The text was updated successfully, but these errors were encountered: