Remove fls(), use pg_bitutils.h facilities instead? - Mailing list pgsql-hackers

From Thomas Munro
Subject Remove fls(), use pg_bitutils.h facilities instead?
Date
Msg-id CA+hUKG+7dSX1XF8yFGmYk-=48dbjH2kmzZj16XvhbrWP-9BzRg@mail.gmail.com
Whole thread Raw
Responses Re: Remove fls(), use pg_bitutils.h facilities instead?
Re: Remove fls(), use pg_bitutils.h facilities instead?
List pgsql-hackers
Hi,

Back in commit 4f658dc8 we gained src/port/fls.c.  As anticipated by
its commit message, we later finished up with something better in
src/include/port/pg_bitutils.h.  fls() ("find last set") is an
off-by-one cousin of pg_leftmost_one_pos32().  I don't know why ffs()
("find first set", the rightmost variant) made it into POSIX while
fls() did not, other than perhaps its more amusing name.  fls() is
present on *BSD, Macs and maybe more, but not everywhere, hence the
configure test.  Let's just do it with pg_bitutils.h instead, and drop
some cruft?  Open to better ideas on whether we need a new function,
or there is some way to use the existing facilities directly without
worrying about undefined behaviour for 0, etc.

Noticed while looking for configure stuff to cull.  Mentioning
separately because this isn't a simple
no-longer-needed-crutch-for-prestandard-system case like the others in
a nearby thread.

Attachment

pgsql-hackers by date:

Previous
From: Thomas Munro
Date:
Subject: Re: Windows now has fdatasync()
Next
From: Bharath Rupireddy
Date:
Subject: Re: Use "WAL segment" instead of "log segment" consistently in user-facing messages