Remove fls(), use pg_bitutils.h facilities instead?

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: David Rowley <dgrowleyml(at)gmail(dot)com>
Subject: Remove fls(), use pg_bitutils.h facilities instead?
Date: 2022-07-20 04:20:46
Message-ID: CA+hUKG+7dSX1XF8yFGmYk-=48dbjH2kmzZj16XvhbrWP-9BzRg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
0001-Remove-replacement-fls-function.patch text/x-patch 10.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2022-07-20 04:32:22 Re: Use "WAL segment" instead of "log segment" consistently in user-facing messages
Previous Message Thomas Munro 2022-07-20 04:14:39 Re: Windows now has fdatasync()