pgsql: Centralize detection of x86 CPU features

From: John Naylor <john(dot)naylor(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Centralize detection of x86 CPU features
Date: 2026-02-27 13:32:08
Message-ID: E1vvxwu-001PVG-1R@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Centralize detection of x86 CPU features

We now maintain an array of booleans that indicate which features were
detected at runtime. When code wants to check for a given feature,
the array is automatically checked if it has been initialized and if
not, a single function checks all features at once.

Move all x86 feature detection to pg_cpu_x86.c, and move the CRC
function choosing logic to the file where the hardware-specific
functions are defined, consistent with more recent hardware-specific
files in src/port.

Reviewed-by: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Discussion: https://postgr.es/m/CANWCAZbgEUFw7LuYSVeJ=Tj98R5HoOB1Ffeqk3aLvbw5rU5NTw@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/16743db061e431d40522547c6436af6616026caa

Modified Files
--------------
src/include/port/pg_cpu.h | 50 ++++++++++++++++++++++
src/port/pg_cpu_x86.c | 65 +++++++++++-----------------
src/port/pg_crc32c_sse42.c | 32 ++++++++++++++
src/port/pg_popcount_x86.c | 91 ++--------------------------------------
src/tools/pgindent/typedefs.list | 1 +
5 files changed, 112 insertions(+), 127 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2026-02-27 17:54:11 pgsql: Don't flatten join alias Vars that are stored within a GROUP RTE
Previous Message Andrew Dunstan 2026-02-27 12:34:34 pgsql: Clean up nodes that are no longer of use in 007_pgdumpall.pl