Messages in this thread | | | From | Alice Ryhl <> | Date | Mon, 8 Apr 2024 11:26:23 +0200 | Subject | Re: [PATCH v4 4/4] rust: add abstraction for `struct page` |
| |
On Mon, Apr 8, 2024 at 11:19 AM Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> wrote: > > On Mon, Apr 8, 2024 at 9:54 AM Alice Ryhl <aliceryhl@google.com> wrote: > > > > From bindgen's point of view, this constant is just an integer literal > > with no type information. So I don't see how we can expect it to > > always be generated as a usize? > > In the case of `PAGE_SIZE`, there is type information (`size_t`), > since it comes from the constant helper: > > const size_t RUST_CONST_HELPER_PAGE_SIZE = PAGE_SIZE; > > For the other one, `PAGE_SHIFT`, there is also type information > (`int`), but bindgen currently picks a type based on the value for > those (but ideally/eventually bindgen should respect it instead). > > So for the former, the allow and the cast are not needed since we are > already handling it explicitly. And for the latter, if we want to have > it as `usize`, we should have the cast but not the allow, because now > it does `u32`, but if it respected the type, it would be `c_int` or > `i32`. So either way we would need the cast.
Good point. Will fix this for next version.
Alice
| |