Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 1 Jun 2023 15:08:04 -0400
From: Rich Felker <dalias@...c.org>
To: Alexander Monakov <amonakov@...ras.ru>
Cc: musl@...ts.openwall.com
Subject: Re: [C23 new stdlib 2/4] C23: add the memalignment function

On Thu, Jun 01, 2023 at 04:35:04PM +0300, Alexander Monakov wrote:
> 
> On Thu, 25 May 2023, Jā‚‘ā‚™ā‚› Gustedt wrote:
> 
> > 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.
> 
> It seems this was unanswered. Hacker's Delight by Henry Warren offers
> a lot of material on such topics. For this particular question it also
> gives the efficient implementation: 'p & -p'.

Wow, I don't know why I didn't realize this being that p&-p is a
common pattern I use... Somehow I didn't see that it was the same
operation.

Rich

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.