From: Miguel Ojeda <ojeda@kernel.org>
To: gregkh@linuxfoundation.org
Cc: aliceryhl@google.com, arve@android.com, christian@brauner.io,
cmllamas@google.com, dualli@google.com, joel@joelfernandes.org,
kernel-team@android.com, linux-kernel@vger.kernel.org,
maco@android.com, rust-for-linux@vger.kernel.org,
surenb@google.com, tkjos@android.com, jbaublitz@redhat.com,
aaron@aaronballman.com, emilio@crisal.io,
christian.poveda@ferrous-systems.com,
Miguel Ojeda <ojeda@kernel.org>
Subject: Re: [PATCH] binder: use enum for binder ioctls
Date: Sat, 9 Dec 2023 22:05:44 +0100 [thread overview]
Message-ID: <20231209210544.139181-1-ojeda@kernel.org> (raw)
In-Reply-To: <2023120936-decency-engraved-5346@gregkh>
> Does this mean that we will have to wrap every ioctl definition in an
> enum just to get access to it in rust code?
Currently, yes (or one can build them on the Rust side using the `_IO*` const
functions that are in mainline at `rust/kernel/ioctl.rs`).
> What makes these defines so magical that bindgen can't decode them? Is
> it just the complexity of the C preprocessor logic involved? Any plans
> for bindgen to resolve this?
Yeah, currently bindgen only resolves "trivial" object-like macros. As soon as
a macro is more complex it does not work, even if it would still resolve into
a constant. The upstream issue for this particular case (a macro that uses
other function-like macros) uses `_IO*`s as the example, in fact, and is at:
https://github.com/rust-lang/rust-bindgen/issues/753
which we track in our bindgen list at:
https://github.com/Rust-for-Linux/linux/issues/353
There are several ways forward for bindgen here. Ideally, libclang would give
the resolved value to bindgen. This may require changes in upstream Clang.
I contacted Aaron Ballman (the Clang maintainer, Cc'd) a while ago and
he kindly offered to review the changes if they were eventually needed.
Otherwise (or meanwhile), it is also possible to implement a workaround that
stores the information in a way that can be retrieved by bindgen by using
the macro in some way (e.g. initializing a variable and asking for the value
of the variable). It is ugly, but it should work (at least for many cases --
there may be other compounding issues with e.g. 128-bit integers).
John Baublitz (Cc'd) has spent some time on this and, from what I can tell from
the issue, we may be waiting on an answer from bindgen (Cc'ing Emilio and
Christian, the bindgen maintainers) on whether the workaround is OK for them.
The workaround would be nice to have even if we change upstream Clang, because
it would help in many cases we care about, without having to wait until we get
a new LLVM released and so on.
Hope that helps!
Cheers,
Miguel
prev parent reply other threads:[~2023-12-09 21:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-08 15:28 [PATCH] binder: use enum for binder ioctls Alice Ryhl
2023-12-08 15:35 ` Carlos Llamas
2023-12-09 9:05 ` Greg Kroah-Hartman
2023-12-09 21:05 ` Miguel Ojeda [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231209210544.139181-1-ojeda@kernel.org \
--to=ojeda@kernel.org \
--cc=aaron@aaronballman.com \
--cc=aliceryhl@google.com \
--cc=arve@android.com \
--cc=christian.poveda@ferrous-systems.com \
--cc=christian@brauner.io \
--cc=cmllamas@google.com \
--cc=dualli@google.com \
--cc=emilio@crisal.io \
--cc=gregkh@linuxfoundation.org \
--cc=jbaublitz@redhat.com \
--cc=joel@joelfernandes.org \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maco@android.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=surenb@google.com \
--cc=tkjos@android.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).