Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <917e05a1-26b9-5e13-006f-85518348c9e9@ispras.ru>
Date: Thu, 1 Jun 2023 16:35:04 +0300 (MSK)
From: Alexander Monakov <amonakov@...ras.ru>
To: musl@...ts.openwall.com
cc: Rich Felker <dalias@...c.org>
Subject: Re: [C23 new stdlib 2/4] C23: add the memalignment function


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

I looked over the recently posted stdbit.h patch and I don't have anything
to suggest in terms of formulas. The things that would worry me are of a
different nature anyway.

Alexander

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.