Re: [PATCH 3/3] rust: pl011: Check size of state struct at compile time

2025-04-05 Thread Peter Maydell
On Thu, 20 Mar 2025 at 15:25, Zhao Liu wrote: > > > -use std::{ffi::CStr, ptr::addr_of_mut}; > > +use std::{ffi::CStr, mem, ptr::addr_of_mut}; > > maybe mem::size_of (since there're 2 use cases :-))? > > > > > use qemu_api::{ > > +bindings, > > chardev::{CharBackend, Chardev, Event}, > >

Re: [PATCH 3/3] rust: pl011: Check size of state struct at compile time

2025-04-04 Thread Zhao Liu
> > > +// Some C users of this device embed its state struct into their own > > > +// structs, so the size of the Rust version must not be any larger > > > +// than the size of the C one. If this assert triggers you need to > > > +// expand the padding_for_rust[] array in the C PL011State struct. >

Re: [PATCH 3/3] rust: pl011: Check size of state struct at compile time

2025-03-20 Thread Zhao Liu
> -use std::{ffi::CStr, ptr::addr_of_mut}; > +use std::{ffi::CStr, mem, ptr::addr_of_mut}; maybe mem::size_of (since there're 2 use cases :-))? > > use qemu_api::{ > +bindings, > chardev::{CharBackend, Chardev, Event}, > +static_assert, This one looks like it breaks the alphabet

[PATCH 3/3] rust: pl011: Check size of state struct at compile time

2025-03-20 Thread Peter Maydell
The PL011 device's C implementation exposes its PL011State struct to users of the device, and one common usage pattern is to embed that struct into the user's own state struct. (The internals of the struct are technically visible to the C user of the device, but in practice are treated as implemen