Re: [PATCH v2] rust: error: add missing error codes

From: Andreas Hindborg
Date: Mon May 15 2023 - 14:13:13 EST



Miguel Ojeda <miguel.ojeda.sandonis@xxxxxxxxx> writes:

> On Tue, May 9, 2023 at 10:46 AM Greg KH <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
>>
>> It depends on which arch you are building for. That's why we have
>> per-platform errno.h files, the values are different for different ones.
>> So you need to handle them all properly somehow. How is rust going to
>> handle per-arch stuff like this?
>
> We can do conditional compilation in the same file, possibly with a
> Rust macro which takes a nice table that shows all arches at once.
>
> We can also split into files like C and move it to each `arch/`, there
> are a couple of approaches for this. This is best for `MAINTAINERS`,
> although these headers almost never change, so it is not a big
> advantage.
>
> We could also automatically do everything based on the C headers, too.
> Back then it felt to me like too much complexity for little gain,
> given those C headers almost never change, but now it may be worth it.
> Or, instead, having a test that verifies they are the same instead,
> and that way we don't introduce complexity for the build itself.
>
> Alice only needs `ERESTARTSYS` so far, as far as I understand, so
> perhaps it is simplest to only add the rest of the non-generic ones
> for the moment; and gather opinions on the approaches above meanwhile.

Let's add the ones we need for now. When we need target specific error
codes we can have a `mod` for each arch, gate behind the target
feature and conditionally reexport them.

BR Andreas