From: | Bastien Roucariès <rouca(at)debian(dot)org> |
---|---|
To: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: Detection of hadware feature => please do not use signal |
Date: | 2024-10-31 20:12:12 |
Message-ID: | 5114283.1BQ3OT5r56@portable-bastien |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Le jeudi 31 octobre 2024, 18:25:34 UTC Tom Lane a écrit :
> Heikki Linnakangas <hlinnaka(at)iki(dot)fi> writes:
> > On 31/10/2024 19:48, Tom Lane wrote:
> >> Maybe we could do it one way on linux and the other way everywhere
> >> else, but I do not find that attractive; it just makes it harder
> >> to get full test coverage.
>
> > Bastien, would you happen to know how other portable libraries that need
> > to run on other operating system do this? We added the SIGILL probe back
> > in 2018, there might be better options available now.
>
> It occurs to me to wonder whether the existing code works on Windows.
> Windows-on-ARM wasn't a thing we thought about in 2018, but it's
> a reasonable target now.
openssl use the following
https://github.com/openssl/openssl/blob/59f5f6c73cd2e1e2bd8ef405fdb6fadf0711f639/crypto/armcap.c#L311
# if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
# if __GLIBC_PREREQ(2, 16)
# include <sys/auxv.h>
# define OSSL_IMPLEMENT_GETAUXVAL
# endif
# elif defined(__ANDROID_API__)
/* see https://developer.android.google.cn/ndk/guides/cpu-features */
# if __ANDROID_API__ >= 18
# include <sys/auxv.h>
# define OSSL_IMPLEMENT_GETAUXVAL
# endif
# endif
# if defined(__FreeBSD__) || defined(__OpenBSD__)
# include <sys/param.h>
# if (defined(__FreeBSD__) && __FreeBSD_version >= 1200000) || \
(defined(__OpenBSD__) && OpenBSD >= 202409)
# include <sys/auxv.h>
# define OSSL_IMPLEMENT_GETAUXVAL
static unsigned long getauxval(unsigned long key)
{
unsigned long val = 0ul;
if (elf_aux_info((int)key, &val, sizeof(val)) != 0)
return 0ul;
return val;
}
# endif
# endif
/*
* Android: according to https://developer.android.com/ndk/guides/cpu-features,
* getauxval is supported starting with API level 18
*/
# if defined(__ANDROID__) && defined(__ANDROID_API__) && __ANDROID_API__ >= 18
# include <sys/auxv.h>
# define OSSL_IMPLEMENT_GETAUXVAL
# endif
/*
* ARM puts the feature bits for Crypto Extensions in AT_HWCAP2, whereas
* AArch64 used AT_HWCAP.
*/
# ifndef AT_HWCAP
# define AT_HWCAP 16
# endif
# ifndef AT_HWCAP2
# define AT_HWCAP2 26
# endif
# if defined(__arm__) || defined (__arm)
# define OSSL_HWCAP AT_HWCAP
# define OSSL_HWCAP_NEON (1 << 12)
# define OSSL_HWCAP_CE AT_HWCAP2
# define OSSL_HWCAP_CE_AES (1 << 0)
# define OSSL_HWCAP_CE_PMULL (1 << 1)
# define OSSL_HWCAP_CE_SHA1 (1 << 2)
# define OSSL_HWCAP_CE_SHA256 (1 << 3)
# elif defined(__aarch64__)
# define OSSL_HWCAP AT_HWCAP
# define OSSL_HWCAP_NEON (1 << 1)
# define OSSL_HWCAP_CE AT_HWCAP
# define OSSL_HWCAP_CE_AES (1 << 3)
# define OSSL_HWCAP_CE_PMULL (1 << 4)
# define OSSL_HWCAP_CE_SHA1 (1 << 5)
# define OSSL_HWCAP_CE_SHA256 (1 << 6)
# define OSSL_HWCAP_CPUID (1 << 11)
# define OSSL_HWCAP_SHA3 (1 << 17)
# define OSSL_HWCAP_CE_SM3 (1 << 18)
# define OSSL_HWCAP_CE_SM4 (1 << 19)
# define OSSL_HWCAP_CE_SHA512 (1 << 21)
# define OSSL_HWCAP_SVE (1 << 22)
/* AT_HWCAP2 */
# define OSSL_HWCAP2 26
# define OSSL_HWCAP2_SVE2 (1 << 1)
# define OSSL_HWCAP2_RNG (1 << 16)
# endif
For windows
https://sources.debian.org/src/xz-utils/5.6.3-1/src/liblzma/check/crc32_arm64.h/?hl=82#L92
>
> regards, tom lane
>
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2024-10-31 20:16:49 | Re: Detection of hadware feature => please do not use signal |
Previous Message | Tyler | 2024-10-31 18:34:38 | Column changes such as an increase in varchar size, can cause extremely slow queries, and postgres should run analyze automatically. |