Skip to content

Commit

Permalink
Extern types: Add netq_t, make them large
Browse files Browse the repository at this point in the history
Merges: #25
  • Loading branch information
chrysn authored Mar 2, 2023
2 parents 4fc2207 + ddd3596 commit 404128d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
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"));

0 comments on commit 404128d

Please sign in to comment.