Skip to content
Open
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
9 changes: 8 additions & 1 deletion sim/mcuboot-sys/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ impl Default for FlashContext {
}
}

#[repr(C)]
// Windows (both mingw and msvc) requires 16-byte alignment for jmp_buf.
// Always align to 16 bytes; the few extra bytes wasted on other platforms
// are immaterial for a struct instantiated a handful of times per test.
#[repr(C, align(16))]
#[derive(Debug)]
pub struct CSimContext {
pub flash_counter: libc::c_int,
Expand All @@ -102,6 +105,10 @@ pub struct CSimContext {
pub boot_jmpbuf: [u64; 48],
}

// Guard against a future field change shifting boot_jmpbuf off a
// 16-byte boundary (struct alignment alone doesn't guarantee this).
const _: () = assert!(mem::offset_of!(CSimContext, boot_jmpbuf) % 16 == 0);

impl Default for CSimContext {
fn default() -> Self {
CSimContext {
Expand Down
Loading