-
Notifications
You must be signed in to change notification settings - Fork 158
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
Vector Implementation #569
Comments
It should be fine in this case. The AAPCS (default As |
Ah, nice digging. Makes sense, thanks! Is there a better type to use than |
I mean, what about something like this: #[repr(C)]
pub struct Vector(usize);
impl Vector {
/// Create a vector with the provided function pointer.
pub fn handler(f: unsafe extern "C" fn()) -> Self {
Self(f as usize)
}
/// Create a vector that is reserved.
pub const fn reserved() -> Self {
Self(0 as usize)
}
} |
Unfortunately For some reason casting pointers as integers is not permitted in |
In the
cortex-m-rt
docs it recommends PACs create aVector
type like so:and this is exactly what PACs do. I'm curious why it is like this? The
reserved
variant being typed asusize
when it should always be0
and constructed like:is very odd to me.
Why not define
Vector
like this:and use it like this:
and why is this type not provided by
cortex-m-rt
so PACs don't have to redefine it every time?I imagine there is some low-level issue with representing the function pointer as a unit pointer that I don't know of.
I am currently using my proposed
Vector
implementation and it does work, I'm just not sure if it is correct.Thanks!
The text was updated successfully, but these errors were encountered: