[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240830160953.768e38c2@eugeo>
Date: Fri, 30 Aug 2024 16:09:53 +0100
From: Gary Guo <gary@...yguo.net>
To: Alice Ryhl <aliceryhl@...gle.com>
Cc: Benno Lossin <benno.lossin@...ton.me>, Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>, Wedson Almeida Filho
<wedsonaf@...il.com>, Boqun Feng <boqun.feng@...il.com>, Björn Roy Baron <bjorn3_gh@...tonmail.com>, Andreas Hindborg
<a.hindborg@...sung.com>, rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] rust: add global lock support
On Fri, 30 Aug 2024 07:34:00 +0200
Alice Ryhl <aliceryhl@...gle.com> wrote:
> > > Due to the initialization requirement, constructing a global mutex is
> > > unsafe with the current approach. In the future, it would be really nice
> > > to support global mutexes that don't need to be initialized, which would
> > > make them safe. Unfortunately, this is not possible today because
> > > bindgen refuses to expose __ARCH_SPIN_LOCK_UNLOCKED to Rust as a
> > > compile-time constant. It just generates an `extern "C"` global
> > > reference instead.
> >
> > Ideally, we would have support for static initialization in pinned-init.
>
> I don't think traits work with const today, so pin-init would need an
> entirely different mechanism? If you're talking about using
> CONSTRUCTORS, then I think it's an undesirable solution. C code can
> define static mutexes without load-time initialization hooks. We
> should be able to do the same.
I think I actually prefer using constructors to unsafe.
Best,
Gary
Powered by blists - more mailing lists