Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 25 May 2023 16:05:01 +0200
From: Jₑₙₛ Gustedt <>
To: Rich Felker <>
Subject: Re: [C23 new stdlib 2/4] C23: add the memalignment function

on Thu, 25 May 2023 09:07:23 -0400 you (Rich Felker <>)

> > 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.)

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.

> See NRK's follow-up. If pure header-only implementations of these
> interfaces met the requirements of the standard, I could see a good
> argument for having implementations there. But if they require
> external functions, I'm not clear on why it makes sense to implement
> inline versions in the headers rather than just letting the compiler
> do its own transformations to inline if/when it wants. This was a path
> glibc went down a long time ago with "bits/string2.h", putting gobs of
> attempted-optimized code in public headers that was suppressing gcc's
> builtin, much better optimizations for the same functions via its
> __builtin_*. I don't think we should repeat that.

Yes, thanks, I understand that strategy much better now.


:: ICube :::::::::::::::::::::::::::::: deputy director ::
:: Université de Strasbourg :::::::::::::::::::::: ICPS ::
:: INRIA Nancy Grand Est :::::::::::::::::::::::: Camus ::
:: :::::::::::::::::::::::::::::::::::: ☎ +33 368854536 ::
:: ::

Content of type "application/pgp-signature" skipped

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.