[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANiq72mMi=7P9OxSH0+ORYDEyxG3+n5uOv_ooxMJ72YRBRZ+PQ@mail.gmail.com>
Date: Fri, 16 Jun 2023 15:48:31 +0200
From: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
To: Andrew Lunn <andrew@...n.ch>
Cc: FUJITA Tomonori <fujita.tomonori@...il.com>, kuba@...nel.org, netdev@...r.kernel.org,
rust-for-linux@...r.kernel.org, aliceryhl@...gle.com
Subject: Re: [PATCH 0/5] Rust abstractions for network device drivers
On Fri, Jun 16, 2023 at 3:14 PM Andrew Lunn <andrew@...n.ch> wrote:
>
> I think this is something you need to get addressed at a language
> level very soon. Lots of netdev API calls will be to macros. The API
> to manipulate skbs is pretty much always used on the hot path, so i
> expect that it will have a large number of macros. It is unclear to me
> how well it will scale if you need to warp them all?
>
> ~/linux/include/linux$ grep inline skbuff.h | wc
> 349 2487 23010
>
> Do you really want to write 300+ wrappers?
It would be very nice if at least `bindgen` (or even the Rust
compiler... :) could cover many of these one-liners. We have discussed
and asked for this in the past, and messages like this reinforce the
need/request for this clearly, so thanks for this.
Since `bindgen` 0.64.0 earlier this year [1] there is an experimental
feature for this (`--wrap-static-fns`), so that is nice -- though we
need to see how well it works. We are upgrading `bindgen` to the
latest version after the merge window, so we can play with this soon.
In particular, given:
static inline int foo(int a, int b) {
return a + b;
}
It generates a C file with e.g.:
#include "a.h"
// Static wrappers
int foo__extern(int a, int b) { return foo(a, b); }
And then in the usual Rust bindings:
extern "C" {
#[link_name = "foo__extern"]
pub fn foo(a: ::std::os::raw::c_int, b: ::std::os::raw::c_int)
-> ::std::os::raw::c_int;
}
Cheers,
Miguel
Powered by blists - more mailing lists