sysutils/lscpu: fix CPU model detection on NetBSD.

# CHANGES

* Improve CPU model detection on NetBSD, by relying on machdep.cpu_brand
  sysctl identifier.
* Mark package as x86/amd64 -only as it leverages on CPUID
  instruction.
* Clarify description.
* Bump revision.
This commit is contained in:
vins 2023-07-11 19:32:00 +00:00
parent 7c053cee67
commit 94857fd454
4 changed files with 29 additions and 9 deletions

View File

@ -1,4 +1,5 @@
lscpu for OpenBSD, FreeBSD, NetBSD, Mac OS X & DragonFly.
The main usage of this program should be for x86 architecture since it
lscpu equivalent for systems based on BSD UNIX.
This utility gathers CPU architecture information on *BSD and macOS.
The main usage of lscpu should be for x86 architecture since it
leverages CPUID instructions. For other architectures, it just shows
very limited facts.

View File

@ -1,6 +1,7 @@
# $NetBSD: Makefile,v 1.2 2023/07/08 21:39:27 vins Exp $
# $NetBSD: Makefile,v 1.3 2023/07/11 19:32:00 vins Exp $
DISTNAME= lscpu-1.2.0
PKGREVISION= 1
CATEGORIES= sysutils
MASTER_SITES= ${MASTER_SITE_GITHUB:=NanXiao/}
@ -9,8 +10,10 @@ HOMEPAGE= https://github.com/NanXiao/lscpu/
COMMENT= The lscpu for BSD
LICENSE= modified-bsd
ONLY_FOR_PLATFORM+= FreeBSD-*-* OpenBSD-*-* NetBSD-*-*
ONLY_FOR_PLATFORM+= DragonFly-*-* Darwin-*-*
.for bsd in FreeBSD OpenBSD NetBSD DragonFly Darwin
ONLY_FOR_PLATFORM+= ${bsd}-*-i386
ONLY_FOR_PLATFORM+= ${bsd}-*-x86_64
.endfor
INSTALLATION_DIRS+= bin ${PKGMANDIR}/man1

View File

@ -1,6 +1,6 @@
$NetBSD: distinfo,v 1.1 2023/07/08 21:29:33 vins Exp $
$NetBSD: distinfo,v 1.2 2023/07/11 19:32:00 vins Exp $
BLAKE2s (lscpu-1.2.0.tar.gz) = a4133355535f08c6f7ccda2b4451d4ae3699654cfd1ae723410ba0b8c7339c51
SHA512 (lscpu-1.2.0.tar.gz) = 4d884c792aa2c91d3b4f860c9054c5f11644c7a91dc6bb2ffe51601348063cedfa946fb49671589d379ed04dfd96fec58a71825df0d0c3eb5a5590f21abeb155
Size (lscpu-1.2.0.tar.gz) = 7863 bytes
SHA1 (patch-lscpu.c) = ee8e55e865330f249f8e66a79b1e66f45b5dc0f5
SHA1 (patch-lscpu.c) = 7d394dbe546b59e81f2185154be8322d65a6086e

View File

@ -1,6 +1,7 @@
$NetBSD: patch-lscpu.c,v 1.1 2023/07/08 21:29:33 vins Exp $
$NetBSD: patch-lscpu.c,v 1.2 2023/07/11 19:32:00 vins Exp $
Fix architecture detection on FreeBSD.
* Fix architecture detection on FreeBSD.
* Fix CPU model detection on NetBSD.
--- lscpu.c.orig 2018-05-05 02:25:31.000000000 +0000
+++ lscpu.c
@ -16,3 +17,18 @@ Fix architecture detection on FreeBSD.
{HW_BYTEORDER, &(gen_info.byte_order), sizeof(gen_info.byte_order), "HW_BYTEORDER"},
{HW_MODEL, gen_info.model, sizeof(gen_info.model), "HW_MODEL"},
{HW_NCPU, &(gen_info.active_cpu_num), sizeof(gen_info.active_cpu_num), "HW_NCPU"},
@@ -972,6 +976,14 @@ int main(int argc, char **argv)
}
}
+#if defined(__NetBSD__) && (defined(__amd64__) || defined(__i386__))
+{
+ size_t sz = sizeof (gen_info.model);
+ if (sysctlbyname("machdep.cpu_brand", gen_info.model, &sz, NULL, 0) == -1)
+ err(1, "MACHDEP.CPU_BRAND");
+}
+#endif
+
#if defined(__amd64__) || defined(__i386__)
get_x86_cpu_info(&x86_info);
#endif