[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANiq72mZ5QPrb1-jWiKFhO2OF517Xvx=Js3zwM+_VyVL=dy2LA@mail.gmail.com>
Date: Mon, 8 Apr 2024 11:18:52 +0200
From: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
To: Alice Ryhl <aliceryhl@...gle.com>
Cc: Benno Lossin <benno.lossin@...ton.me>, Miguel Ojeda <ojeda@...nel.org>,
Matthew Wilcox <willy@...radead.org>, Al Viro <viro@...iv.linux.org.uk>,
Andrew Morton <akpm@...ux-foundation.org>, Kees Cook <keescook@...omium.org>,
Alex Gaynor <alex.gaynor@...il.com>, Wedson Almeida Filho <wedsonaf@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Andreas Hindborg <a.hindborg@...sung.com>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Arve Hjønnevåg <arve@...roid.com>,
Todd Kjos <tkjos@...roid.com>, Martijn Coenen <maco@...roid.com>,
Joel Fernandes <joel@...lfernandes.org>, Carlos Llamas <cmllamas@...gle.com>,
Suren Baghdasaryan <surenb@...gle.com>, Arnd Bergmann <arnd@...db.de>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org,
Christian Brauner <brauner@...nel.org>
Subject: Re: [PATCH v4 4/4] rust: add abstraction for `struct page`
On Mon, Apr 8, 2024 at 9:54 AM Alice Ryhl <aliceryhl@...gle.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.
Cheers,
Miguel
Powered by blists - more mailing lists