Re: Detection of hadware feature => please do not use signal

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Bastien Roucariès <rouca(at)debian(dot)org>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: Detection of hadware feature => please do not use signal
Date: 2024-10-31 17:29:45
Message-ID: af84e934-4e9c-4380-95ee-8921dab1254b@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 31/10/2024 17:41, Bastien Roucariès wrote:
> Hi,
>
> On debian side we will like to avoid use of sigill to detect feature.
>
> https://sources.debian.org/src/postgresql-17/17.0-1/src/port/pg_crc32c_armv8_choose.c/#L55
>
> is really bad.

Why is it bad?

> Could you use the canonical way under linux
>
> #include <sys/auxv.h>
> #include <asm/hwcap.h>
>
> #if defined(__aarch64__)
> return !(getauxval(AT_HWCAP) & HWCAP_CRC32);
> #else
> return !(getauxval(AT_HWCAP2) & HWCAP2_CRC32);
> #endif

We used to do that, but it was changed in commit 1c72ec6f. Looking at
the discussion that led to it, it's not clear to me why we switched [1].
Portablity to non-glibc systems maybe?

If there's a handy, portable way to check CPU capabilities, I agree it
seem less hacky than catching SIGILL...

[1]
https://www.postgresql.org/message-id/CAEepm%3D02Run-Pk3xyt%2BRV3p1N%2B7cKZxN95_MamaJw8Cnw%2BDwjQ%40mail.gmail.com

--
Heikki Linnakangas
Neon (https://neon.tech)

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bastien Roucariès 2024-10-31 17:42:09 Re: Detection of hadware feature => please do not use signal
Previous Message Bastien Roucariès 2024-10-31 15:41:24 Detection of hadware feature => please do not use signal