Re: [PATCH 1/4] rust: dma: implement DataDirection
From: Miguel Ojeda
Date: Mon Aug 18 2025 - 08:35:48 EST
On Mon, Aug 18, 2025 at 1:56 PM Miguel Ojeda
<miguel.ojeda.sandonis@xxxxxxxxx> wrote:
>
> Yes, it can easily pick `u32` -- the variants are always `int` in C,
And, for completeness, if the kernel eventually uses C23 enums (I
don't see any, from a quick grep), i.e. with an underlying type, then
in C the variants will actually have that type, not `int`:
enum c23_enum : short { c23_enum_a, c23_enum_b };
_Static_assert(_Generic(c23_enum_a, short: 1, default: 0), "");
_Static_assert(_Generic(c23_enum_b, short: 1, default: 0), "");
_Static_assert(_Generic((enum c23_enum)0, short: 1, default: 0), "");
And `bindgen` will have the underlying type too, so everything matches
in that case:
pub const c23_enum_c23_enum_a: c23_enum = 0;
pub const c23_enum_c23_enum_b: c23_enum = 1;
pub type c23_enum = ffi::c_short;
So, in a way, what `bindgen` tries to do (for the normal ones) is
behave a bit like these new ones.
But I always wondered if it is good or not differing there.
Cheers,
Miguel