Re: [PATCH] rust: move #define __rust_helper out of atomic.c

From: Alice Ryhl

Date: Wed Jan 07 2026 - 12:20:17 EST


On Wed, Jan 7, 2026 at 5:10 PM Boqun Feng <boqun.feng@xxxxxxxxx> wrote:
>
> On Wed, Jan 07, 2026 at 02:14:13PM +0000, Alice Ryhl wrote:
> > We were lucky that atomic.c is the first file in helpers.c so that we
> > may use the define from it in the follow-up headers [1], but this is
> > fragile. Thus, move it to helpers.c.
> >
>
> I reword a bit to make it clear that we need this changes for inline
> helpers:
>
> In order to support inline helpers [1], we need to have __rust_helper
> defined for all helper files. Current we are lucky that atomic.c is the
> first file in helpers.c, but this is fragile. Thus, move it to
> helpers.c.
>
> Let me know if you have futher suggestion.

Sounds good to me.

> > diff --git a/scripts/atomic/gen-rust-atomic-helpers.sh b/scripts/atomic/gen-rust-atomic-helpers.sh
> > index 45b1e100ed7c63108ee6cb07e48a17668f860d47..a3732153af29f415e397e17cab6e75cb5d7efafc 100755
> > --- a/scripts/atomic/gen-rust-atomic-helpers.sh
> > +++ b/scripts/atomic/gen-rust-atomic-helpers.sh
>
> whenever we changed scripts/atomic/* we need to rerun
> scripts/atomic/gen-atomics.sh to calculate a new hash value of the
> generated files, so we are missing this:

I tried running it but I got an error from grep about no file input or
something like that. I couldn't figure out what argument I needed to
pass to the script.

> diff --git a/rust/helpers/atomic.c b/rust/helpers/atomic.c
> index a48605628ed7..4b24eceef5fc 100644
> --- a/rust/helpers/atomic.c
> +++ b/rust/helpers/atomic.c
> @@ -1032,4 +1032,4 @@ rust_helper_atomic64_dec_if_positive(atomic64_t *v)
> }
>
> #endif /* _RUST_ATOMIC_API_H */
> -// 615a0e0c98b5973a47fe4fa65e92935051ca00ed
> +// e4edb6174dd42a265284958f00a7cea7ddb464b1
>
> I queued with this change for the rust-sync PR of 7.0, thanks!

Thanks!

Alice