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 1tEj2t-009JNu-Hz for pgsql-bugs@arkaria.postgresql.org; Sat, 23 Nov 2024 05:51:03 +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 1tEj2r-00Fmdm-Bz for pgsql-bugs@arkaria.postgresql.org; Sat, 23 Nov 2024 05:51:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tEj2r-00Fmde-3K for pgsql-bugs@lists.postgresql.org; Sat, 23 Nov 2024 05:51:01 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tEj2n-003Ocp-JP for pgsql-bugs@lists.postgresql.org; Sat, 23 Nov 2024 05:51:00 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 4AN5okqg736757; Sat, 23 Nov 2024 00:50:46 -0500 From: Tom Lane To: Thomas Munro cc: Heikki Linnakangas , =?UTF-8?Q?Bastien_Roucari=C3=A8s?= , pgsql-bugs@lists.postgresql.org Subject: Re: Detection of hadware feature => please do not use signal In-reply-to: References: <4496616.iHFcN1HehY@portable-bastien> <1156374.1730396928@sss.pgh.pa.us> <7ec1c65c-1a28-49a7-af43-f77c260a3df6@iki.fi> <1292593.1730399134@sss.pgh.pa.us> <707008.1732325995@sss.pgh.pa.us> Comments: In-reply-to Thomas Munro message dated "Sat, 23 Nov 2024 18:10:17 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <736755.1732341046.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 23 Nov 2024 00:50:46 -0500 Message-ID: <736756.1732341046@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Thomas Munro writes: > (Nerd sniped) No NetBSD here but think a 32 bit kernel should expose > sysctl machdep.id_isar, which should be an array of 6 ints, and bits > 16-19 of id_isar[5] should give you the answer: Huh. cpuctl's arm32 module knows of machdep.id_isar, but it does not appear to know that that word exists: http://cvsweb.netbsd.org/bsdweb.cgi/src/usr.sbin/cpuctl/arch/arm.c?rev=3D1= .6;content-type=3Dtext%2Fplain But that developer.arm.com page seems pretty definitive. Tomorrow I'll have a go at spinning up a 32-bit NetBSD installation and test it. Thanks for the research! > Since you included , and only care about non-zero, > couldn't you use the mask from the header, instead of all that > bitswizzling? > return (id->ac_aa64isar0 & ID_AA64ISAR0_EL1_CRC32) !=3D 0; I didn't actually look into that header ;-) ... I was just basing this on what cpuctl's code does. That version does look cleaner, at least for aarch64 --- but given that the field is defined to be in the same place in the relevant register for each arch, I'm a bit inclined to keep the bit-swizzling and just have two paths for getting the register contents. Unless maybe that header is also installed in arm32 builds, in which case we could do it as you show for both arches. I'll find out ma=C3=B1ana. regards, tom lane