mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: "Jₑₙₛ Gustedt" <jens.gustedt@inria.fr>
Cc: musl@lists.openwall.com
Subject: Re: [musl] [C23 new stdlib 2/4] C23: add the memalignment function
Date: Thu, 25 May 2023 10:34:15 -0400	[thread overview]
Message-ID: <20230525143415.GJ4163@brightrain.aerifal.cx> (raw)
In-Reply-To: <20230525160501.787872b2@inria.fr>

On Thu, May 25, 2023 at 04:05:01PM +0200, Jₑₙₛ Gustedt wrote:
> 
> on Thu, 25 May 2023 09:07:23 -0400 you (Rich Felker <dalias@libc.org>)
> wrote:
> 
> > > So you want me to use the ctz and clz interfaces from the internal
> > > atomics for the implementation of <stdbit.h>? Are they not overkill
> > > for this simple purpose? (I mean they are meant to be atomic,
> > > arent't they?)  
> > 
> > No, I think you're mixing up code which is part of musl and code which
> > is (included as) part of the application. atomic.h is a musl
> > implementation detail and is not even present for application code
> > included from stdbit.h to use.
> 
> I am not clear to which question you are answering "no". Fact is that
> these functions are used for `ffs` and friends, so they are the
> natural candidates to base the implementation upon. (`ffs` cannot be
> used directly because they have intefaces with signed integers.)

OK, maybe I misunderstood. They can and should be used in musl sources
for implementing these interfaces as external functions, just not for
macro definitions in the headers. I thought we were talking about the
latter.

It looks like the primitives we have cover everything needed for
stdbit.h functions except popcnt. Not sure what the best way to add
that is. Perhaps with a new a_popcnt that archs can override. This
would also allow configure to probe for a builtin and select use of
that if desired. It looks like that generates a call to libgcc on
archs with no native version.

> I'd very much like to avoid to reinvent the wheel, here, and in the
> internal code that I have looked at I have not detected much which
> would be specific for atomics. But maybe I am overlooking something,
> thus the question.

Having them in "atomics" is a historical misnomer, but it's vacuous
since they operate on values not objects. The effort to move them to a
separate file and setup per-arch machinery for defining them there is
nontrivial and the value seems near-zero, so I haven't pursued it.

Rich

  reply	other threads:[~2023-05-25 14:34 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-24 19:38 [musl] [C23 new stdlib 0/4] changes in stdlib.h Jens Gustedt
2023-05-24 19:38 ` [musl] [C23 new stdlib 1/4] C23: add the new interfaces free_sized and free_aligned_sized for stdlib.h Jens Gustedt
2023-05-24 21:31   ` Rich Felker
2023-05-25  9:38     ` Jₑₙₛ Gustedt
2023-05-25 12:57       ` Rich Felker
2023-05-24 19:38 ` [musl] [C23 new stdlib 2/4] C23: add the memalignment function Jens Gustedt
2023-05-24 21:28   ` Rich Felker
2023-05-24 22:12     ` Rich Felker
2023-05-25  9:17       ` Jₑₙₛ Gustedt
2023-05-25  9:16     ` Jₑₙₛ Gustedt
2023-05-25  9:42       ` NRK
2023-05-25 13:07       ` Rich Felker
2023-05-25 14:05         ` Jₑₙₛ Gustedt
2023-05-25 14:34           ` Rich Felker [this message]
2023-05-25 15:22             ` Jₑₙₛ Gustedt
2023-06-01 13:35       ` Alexander Monakov
2023-06-01 19:08         ` Rich Felker
2023-06-02  8:07           ` Jₑₙₛ Gustedt
2023-06-02  8:03         ` Jₑₙₛ Gustedt
2023-06-02  8:37           ` Alexander Monakov
2023-05-24 19:38 ` [musl] [C23 new stdlib 3/4] C23: implement the new strfrom[dfl] functions Jens Gustedt
2023-05-24 21:42   ` Rich Felker
2023-05-24 19:38 ` [musl] [C23 new stdlib 4/4] C23: add the new include guard to stdlib.h Jens Gustedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230525143415.GJ4163@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=jens.gustedt@inria.fr \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).