Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t6beH-00EAQJ-I2 for pgsql-bugs@arkaria.postgresql.org; Thu, 31 Oct 2024 20:20:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t6beE-005nkg-S9 for pgsql-bugs@arkaria.postgresql.org; Thu, 31 Oct 2024 20:20:03 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t6bWn-005iIB-Oj for pgsql-bugs@lists.postgresql.org; Thu, 31 Oct 2024 20:12:22 +0000 Received: from stravinsky.debian.org ([2001:41b8:202:deb::311:108]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t6bWl-003qIJ-Aj for pgsql-bugs@lists.postgresql.org; Thu, 31 Oct 2024 20:12:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=ip7czAVF5aUneYON8n41HEayMH0s58uIWgFmC/zSXAY=; b=b9ygkJzBi5rVygJPZXmalmEpVv t9AZZYPbctd2d5vGhMdWXVoym0uOVyJfu73pLlT3xo11run6f1c8VJOMOvuJeH4fl4skRdEyOjlWL qCoEpzQ/AkmscmGvXSLoe36BdXqPV9l7A55V+IPXVLCyihMR3U7A4j0u7AV9oXKmsKyvulSBi3Lsp hD+gEI1S0iauv4d6Khr8s7d1ceFRgbv6bSSm+Kquv19L7ofHV9vgT5Mz+3Ne12CzA9LWFCPUfwX5q JjrSMWfzebIVaPAiOLSNeckrmtm/BDzK63nmEF9ytJcthcTJVGMXCAYN8ZUD/irvGg83cPoHbfryc tzX6PKeA==; Received: from authenticated user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94.2) (envelope-from ) id 1t6bWf-009GZO-G6; Thu, 31 Oct 2024 20:12:15 +0000 From: Bastien =?ISO-8859-1?Q?Roucari=E8s?= To: Heikki Linnakangas , Tom Lane Cc: pgsql-bugs@lists.postgresql.org Subject: Re: Detection of hadware feature => please do not use signal Date: Thu, 31 Oct 2024 20:12:12 +0000 Message-ID: <5114283.1BQ3OT5r56@portable-bastien> In-Reply-To: <1292593.1730399134@sss.pgh.pa.us> References: <4496616.iHFcN1HehY@portable-bastien> <7ec1c65c-1a28-49a7-af43-f77c260a3df6@iki.fi> <1292593.1730399134@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart3337701.h7IPQuyvLu"; micalg="pgp-sha512"; protocol="application/pgp-signature" X-Debian-User: rouca List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --nextPart3337701.h7IPQuyvLu Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8"; protected-headers="v1" From: Bastien =?ISO-8859-1?Q?Roucari=E8s?= To: Heikki Linnakangas , Tom Lane Cc: pgsql-bugs@lists.postgresql.org Subject: Re: Detection of hadware feature => please do not use signal Date: Thu, 31 Oct 2024 20:11:58 +0000 Message-ID: <5114283.1BQ3OT5r56@portable-bastien> In-Reply-To: <1292593.1730399134@sss.pgh.pa.us> MIME-Version: 1.0 Le jeudi 31 octobre 2024, 18:25:34 UTC Tom Lane a =C3=A9crit : > Heikki Linnakangas 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. >=20 > > Bastien, would you happen to know how other portable libraries that nee= d=20 > > to run on other operating system do this? We added the SIGILL probe bac= k=20 > > in 2018, there might be better options available now. >=20 > 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/59f5f6c73cd2e1e2bd8ef405fdb6fadf071= 1f639/crypto/armcap.c#L311 # if defined(__GLIBC__) && defined(__GLIBC_PREREQ) # if __GLIBC_PREREQ(2, 16) # include # define OSSL_IMPLEMENT_GETAUXVAL # endif # elif defined(__ANDROID_API__) /* see https://developer.android.google.cn/ndk/guides/cpu-features */ # if __ANDROID_API__ >=3D 18 # include # define OSSL_IMPLEMENT_GETAUXVAL # endif # endif # if defined(__FreeBSD__) || defined(__OpenBSD__) # include # if (defined(__FreeBSD__) && __FreeBSD_version >=3D 1200000) || \ (defined(__OpenBSD__) && OpenBSD >=3D 202409) # include # define OSSL_IMPLEMENT_GETAUXVAL static unsigned long getauxval(unsigned long key) { unsigned long val =3D 0ul; if (elf_aux_info((int)key, &val, sizeof(val)) !=3D 0) return 0ul; return val; } # endif # endif /* * Android: according to https://developer.android.com/ndk/guides/cpu-featu= res, * getauxval is supported starting with API level 18 */ # if defined(__ANDROID__) && defined(__ANDROID_API__) && __ANDROID_API__ >= =3D 18 # include # 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 =46or windows https://sources.debian.org/src/xz-utils/5.6.3-1/src/liblzma/check/crc32_arm= 64.h/?hl=3D82#L92 >=20 > regards, tom lane >=20 --nextPart3337701.h7IPQuyvLu Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: 7Bit -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEXQGHuUCiRbrXsPVqADoaLapBCF8FAmcj5I4ACgkQADoaLapB CF+a+w/8DWAFro2mMQnhuwogcpOfuH/xw8WEoJxAbMX6GxxNdaWWou8v5Aqc3UDM lHJYs7xVF2Uw+WyJIHOKB9JCtSdsNLM/ficGCSzbMB1Dau5FeoQqHMerdCq56gQp 4LhtoF1uYA+kMAe6ptFtw1c8FA6rsLl1eGjfrFLUgugBUf4LeLLblxzqKVWjWHNE ksHKaBkxX503uWqArflpF5Db3z0WgSe2MliJSat92Bdw/VPgG+wD7nwt+UG3Fkct 4+XG6pCIfDrClLFU4effgE2o8eSr8rKpA6AYcN8G4wAbss+OIKCF6TRF5n8Ehi+Q NqW/FRmcpI+U+bgXdue1TAJXT5pJijcM78Z+cL3yH5QMfIXTMTjsXN9RoJ/2oV9O v+vSX8XUhcbeALB8joaZlX6iD5LmFMgfPKJPnv5oJLyyVJL4E/3mpH8aBN8AgXE7 JWAV5+hNlqMVts7RFayW19f9fLu8lRgf2C2qEmhu5Zo3DvgwY9vFc37hmEnY6mWg 3kLPRjUswgLis/1FAawDDCsi0zUc+g/s/C27CDt9ZlPLHy5JHm4ycy8hyCBMwxDm zxOkXVKZPVVq57tyliH4yZqNhlMX0PjO8BE8FZGWG02ZGDpF/mrgp3MW2UAat90O wp1ie8fP6ZAbUAPL2TKXJerughuANM8lvTI284VqKWUZn9ToyCQ= =1dNT -----END PGP SIGNATURE----- --nextPart3337701.h7IPQuyvLu--