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

Extern types: Add netq_t, make them large #25

Merged
merged 2 commits into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ fn main() {
rustcode = rustcode.replace("\n pub type _IO_codecvt;", "");
rustcode = rustcode.replace("\n pub type _IO_marker;", "");
rustcode = rustcode.replace("\n pub type __lock;", "");
rustcode = rustcode.replace("\n pub type netq_t;", "");
}

// Replace the function declarations with ... usually something pub, but special considerations
Expand Down
17 changes: 11 additions & 6 deletions src/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,22 @@ use cty as libc;
use c2rust_bitfields::*;

// This is a replacement for the `pub type __locale_t` and the IO lines that C2Rust generates
// because of something from stdlib; it is stripped out of the compiled code and turned into a void
// because of something from stdlib; it is stripped out of the compiled code and turned into a u8
// pointer for lack of better ideas. (Leaving it as a pub struct would require unstable Rust).
//
// The type is hugely sized to ensure that things crash (or preferably don't build) if at any point
// Rust code tries to touch an instance of it, eg. by allocating one on the stack or statically.
#[cfg(not(feature = "keep-extern-types"))]
pub type __locale_t = libc::c_void;
pub type __locale_t = [u8; isize::MAX as _];
#[cfg(not(feature = "keep-extern-types"))]
pub type _IO_wide_data = libc::c_void;
pub type _IO_wide_data = [u8; isize::MAX as _];
#[cfg(not(feature = "keep-extern-types"))]
pub type _IO_codecvt = libc::c_void;
pub type _IO_codecvt = [u8; isize::MAX as _];
#[cfg(not(feature = "keep-extern-types"))]
pub type _IO_marker = libc::c_void;
pub type _IO_marker = [u8; isize::MAX as _];
#[cfg(not(feature = "keep-extern-types"))]
pub type __lock = libc::c_void;
pub type __lock = [u8; isize::MAX as _];
#[cfg(not(feature = "keep-extern-types"))]
pub type netq_t = [u8; isize::MAX as _];

include!(concat!(env!("OUT_DIR"), "/riot_c2rust_replaced.rs"));