From: | Michael Paquier <michael(at)paquier(dot)xyz> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Remove traces of long in dynahash.c |
Date: | 2025-08-20 07:40:21 |
Message-ID: | aKV75fqbwcnlPMrw@paquier.xyz |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Aug 19, 2025 at 10:46:58AM -0400, Tom Lane wrote:
> +1 for getting rid of those while we're doing janitorial work here.
> They're not *quite* duplicates though, for instance next_pow2_int has
> different response to out-of-range values than pg_nextpower2_32.
This would mean introducing more flavors in pg_bitutils.h with limit
checks. That does not seem completely right to do in this file, which
is a wrapper for all the __builtin_*() calls? A second point is on
the signedness but we could just cap the maximum at
(PG_UINT{32,64}_MAX / 2), I guess, with two new routines like:
uint64 pg_nextpower2_64_max(uint64 num);
uint32 pg_prevpower2_32_max(uint32 num);
And then cast the unsigned results back to signed in dynahash.c.
Without this point, I have switched the patch to use int64, keeping
the signedness the same as the original. I have missed that there was
one spot where we relied on NO_MAX_DSIZE.
--
Michael
Attachment | Content-Type | Size |
---|---|---|
v2-0001-Replace-uses-of-long-by-int64-in-dynahash.c-and-h.patch | text/x-diff | 15.5 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Hayato Kuroda (Fujitsu) | 2025-08-20 07:42:11 | RE: ReplicationSlotRelease() crashes when the instance is in the single user mode |
Previous Message | Andrei Lepikhov | 2025-08-20 07:33:12 | Re: Organize working memory under per-PlanState context |