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

use repr C to suppress not-ffi-safe when used with extern handler functions #94

Merged
merged 1 commit into from Nov 18, 2019

Conversation

@cmsd2
Copy link
Contributor

cmsd2 commented Nov 18, 2019

the interrupt handler functions are extern to allow for the special calling convention.
rust warns about using this struct with extern functions.
this patch suppresses the warning by fixing the struct layout.

i think in this case the warning is correctly pointing out that while the nested InterruptStackFrameValue is repr(C), the wrapper type is not. it seems incredibly unlikely that the compiler would do anything wrong here but adding repr(C) guards against it.

example warning:

   Compiling libkernel v0.1.0 (/Users/cmsd2/Development/ostoo/libkernel)
warning: `extern` fn uses type `x86_64::structures::idt::InterruptStackFrame`, which is not FFI-safe
  --> libkernel/src/interrupts.rs:70:18
   |
70 |     stack_frame: &mut InterruptStackFrame)
   |                  ^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
   |
   = note: `#[warn(improper_ctypes)]` on by default
   = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
   = note: this struct has unspecified layout
…th extern interrupt handler functions
@phil-opp

This comment has been minimized.

Copy link
Member

phil-opp commented Nov 18, 2019

Thanks a lot!

@phil-opp phil-opp merged commit d082e7b into rust-osdev:master Nov 18, 2019
9 checks passed
9 checks passed
Test (ubuntu-latest)
Details
Test (macos-latest)
Details
Test (windows-latest)
Details
Check Formatting
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
rust-osdev.x86_64 Build #20191118.1 succeeded
Details
rust-osdev.x86_64 (Job linux) Job linux succeeded
Details
rust-osdev.x86_64 (Job mac) Job mac succeeded
Details
rust-osdev.x86_64 (Job windows) Job windows succeeded
Details
phil-opp added a commit that referenced this pull request Nov 18, 2019
@phil-opp

This comment has been minimized.

Copy link
Member

phil-opp commented Nov 18, 2019

Published as version 0.7.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.