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 11:16:53 +0200
From: Jₑₙₛ Gustedt <jens.gustedt@...ia.fr>
To: Rich Felker <dalias@...c.org>
Cc: musl@...ts.openwall.com
Subject: Re: [C23 new stdlib 2/4] C23: add the memalignment function

Rich,

on Wed, 24 May 2023 17:28:35 -0400 you (Rich Felker <dalias@...c.org>)
wrote:

> There's a more efficient implementation of this function which does
> not depend on __builtin_ctzll (which we don't): p^(p-1)&p

yes, nice

If you have other such nice formulas for some of the interfaces in
<stdbit.h>, please let me know. They are hard to find in search
engines.

For `__builtin_ctzll`, hm, I counted also to use these for the
<stdbit.h> interfaces. I think the intent of those is really to
provide instruction level support of these bit functionalities that
avoids going through function calls.

I see that we use other quite specific builtins, such as
`__builtin_fma`. Is there a particular reason not to have the bit
level ones?

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

> I'm not clear that there's a really good motivation for having it
> implemented in the header. It kinda falls under the "maybe do it
> because it's easy" case, but once you switch to the non-GNUC-specific
> version, it needs a static inline function to avoid multiple
> evaluation,

I guess using `({ ... })` would also not be acceptable?

> and then it gets to the point of "this is really too much
> code to have in a header" (which is more an issue of avoiding
> "creative" content in headers than anything else).

You probably won't like what I have now for the bit operations, then
:-(


Thanks
Jₑₙₛ

-- 
:: ICube :::::::::::::::::::::::::::::: deputy director ::
:: Université de Strasbourg :::::::::::::::::::::: ICPS ::
:: INRIA Nancy Grand Est :::::::::::::::::::::::: Camus ::
:: :::::::::::::::::::::::::::::::::::: ☎ +33 368854536 ::
:: https://icube-icps.unistra.fr/index.php/Jens_Gustedt ::

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.