[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Z6URl_IzpHgxfIdw@cassiopeiae>
Date: Thu, 6 Feb 2025 20:46:31 +0100
From: Danilo Krummrich <dakr@...nel.org>
To: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
Cc: Alejandro Colomar <alx@...nel.org>, Tamir Duberstein <tamird@...il.com>,
Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] rust: alloc: satisfy `aligned_alloc` requirements
On Thu, Feb 06, 2025 at 08:37:07PM +0100, Miguel Ojeda wrote:
> On Thu, Feb 6, 2025 at 7:58 PM Danilo Krummrich <dakr@...nel.org> wrote:
> >
> > What makes you think so?
> >
> > AFAICS, the man page applies for posix_memalign, aligned_alloc, memalign,
> > valloc and pvalloc.
> >
> > In case behavior differs between the functions, this is stated explicitly, e.g.
> > in the "RETURN VALUE" section.
> >
> > The "ERRORS" setion does not differentiate, hence it should apply to all the
> > functions above, including aligned_alloc.
> >
> > Do I miss anything?
>
> The explanation of the requirements (in the Linux man page) mention
> different requirements for each function.
Indeed, it seems a bit ambiguous.
>
> Moreover, in practice, glibc seemed to allow almost any alignment up
> to 2023, and since then they have this:
>
> +/* Similar to memalign, but starting with ISO C17 the standard
> + requires an error for alignments that are not supported by the
> + implementation. Valid alignments for the current implementation
> + are non-negative powers of two. */
> + if (!powerof2 (alignment) || alignment == 0)
> + {
> + __set_errno (EINVAL);
> + return 0;
> + }
Agree, in practice no concern from my side either.
>
> Including a test that does not fail for a degenerate alignment (1).
> Thus I don't think the "multiple of sizeof" part applies today or in
> the past for that implementation (again, in practice).
>
> But I don't know how those sections are formally supposed to work or
> what requirements (and/or behavior) the man pages are supposed to be
> documenting -- Cc'ing Alejandro. It seems clarifying the page would
> help.
+1
Powered by blists - more mailing lists