From c23917c0adfd17bb34a2cc2c0442cd1cefe1dd72 Mon Sep 17 00:00:00 2001 From: nikita Date: Tue, 12 Apr 2022 22:22:26 +0000 Subject: libcpuid: Add version 0.5.1 libcpuid provides CPU identification for the x86 (and x86_64). For details about the programming API, you might want to take a look at the project's website on sourceforge (http://libcpuid.sourceforge.net/). There you'd find a short tutorial, as well as the full API reference. --- sysutils/Makefile | 3 +- sysutils/libcpuid/DESCR | 5 ++ sysutils/libcpuid/Makefile | 27 +++++++++++ sysutils/libcpuid/PLIST | 7 +++ sysutils/libcpuid/distinfo | 7 +++ sysutils/libcpuid/patches/patch-configure.ac | 34 +++++++++++++ .../patches/patch-libcpuid_libcpuid_util.c | 56 ++++++++++++++++++++++ 7 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 sysutils/libcpuid/DESCR create mode 100644 sysutils/libcpuid/Makefile create mode 100644 sysutils/libcpuid/PLIST create mode 100644 sysutils/libcpuid/distinfo create mode 100644 sysutils/libcpuid/patches/patch-configure.ac create mode 100644 sysutils/libcpuid/patches/patch-libcpuid_libcpuid_util.c diff --git a/sysutils/Makefile b/sysutils/Makefile index ac3dd4db77f..1f7df221720 100644 --- a/sysutils/Makefile +++ b/sysutils/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.1000 2022/03/12 14:28:54 tnn Exp $ +# $NetBSD: Makefile,v 1.1001 2022/04/12 22:22:26 nikita Exp $ # COMMENT= System utilities @@ -389,6 +389,7 @@ SUBDIR+= lf SUBDIR+= libbaloo4 SUBDIR+= libburn SUBDIR+= libcap +SUBDIR+= libcpuid SUBDIR+= libdevkit-gobject SUBDIR+= libfm SUBDIR+= libfm-extra diff --git a/sysutils/libcpuid/DESCR b/sysutils/libcpuid/DESCR new file mode 100644 index 00000000000..6bc79fe6eb1 --- /dev/null +++ b/sysutils/libcpuid/DESCR @@ -0,0 +1,5 @@ +libcpuid provides CPU identification for the x86 (and x86_64). For +details about the programming API, you might want to take a look at +the project's website on sourceforge +(http://libcpuid.sourceforge.net/). There you'd find a short tutorial, +as well as the full API reference. diff --git a/sysutils/libcpuid/Makefile b/sysutils/libcpuid/Makefile new file mode 100644 index 00000000000..052e0a48677 --- /dev/null +++ b/sysutils/libcpuid/Makefile @@ -0,0 +1,27 @@ +# $NetBSD: Makefile,v 1.1 2022/04/12 22:22:26 nikita Exp $ + +DISTNAME= v${VERSION} +PKGNAME= ${GITHUB_PROJECT}-${DISTNAME:S,^v,,} +VERSION= 0.5.1 +GITHUB_PROJECT= libcpuid +GITHUB_TAG= ${DISTNAME} +CATEGORIES= sysutils +MASTER_SITES= ${MASTER_SITE_GITHUB:=anrieff/} +DIST_SUBDIR= ${GITHUB_PROJECT} + +MAINTAINER= pkgsrc-users@NetBSD.org +HOMEPAGE= https://github.com/anrieff/libcpuid/ +COMMENT= Small x86 CPU identification library +LICENSE= 2-clause-bsd + +GNU_CONFIGURE= yes +USE_LIBTOOL= yes +USE_LANGUAGES= c +USE_TOOLS= autoconf automake + +pre-configure: + cd ${WRKSRC} && autoreconf --install + +# only for a couple of archs, specify here. + +.include "../../mk/bsd.pkg.mk" diff --git a/sysutils/libcpuid/PLIST b/sysutils/libcpuid/PLIST new file mode 100644 index 00000000000..1b0ccc4a901 --- /dev/null +++ b/sysutils/libcpuid/PLIST @@ -0,0 +1,7 @@ +@comment $NetBSD: PLIST,v 1.1 2022/04/12 22:22:26 nikita Exp $ +bin/cpuid_tool +include/libcpuid/libcpuid.h +include/libcpuid/libcpuid_constants.h +include/libcpuid/libcpuid_types.h +lib/libcpuid.la +lib/pkgconfig/libcpuid.pc diff --git a/sysutils/libcpuid/distinfo b/sysutils/libcpuid/distinfo new file mode 100644 index 00000000000..b8b36e6a29d --- /dev/null +++ b/sysutils/libcpuid/distinfo @@ -0,0 +1,7 @@ +$NetBSD: distinfo,v 1.1 2022/04/12 22:22:26 nikita Exp $ + +BLAKE2s (libcpuid/v0.5.1.tar.gz) = 66c0d89cdf0350649581ff01aabaa032eafdf74f5f24d998ad4e735f81bea8cd +SHA512 (libcpuid/v0.5.1.tar.gz) = d725bc82e5aa2db69cea7b3590afbe11d6028cf4802fde8d498b4f1cc6d823e73d71b89a453d81bf996d97b36a71f6c00d0f6e8292b72f2be8a64b5d59c01861 +Size (libcpuid/v0.5.1.tar.gz) = 166522 bytes +SHA1 (patch-configure.ac) = 130cf88478f611b2b96f17a7040d5733eb492a5d +SHA1 (patch-libcpuid_libcpuid_util.c) = 2b041a0829ff23acf8f6adf741d9427879cab363 diff --git a/sysutils/libcpuid/patches/patch-configure.ac b/sysutils/libcpuid/patches/patch-configure.ac new file mode 100644 index 00000000000..a9fa7599e69 --- /dev/null +++ b/sysutils/libcpuid/patches/patch-configure.ac @@ -0,0 +1,34 @@ +$NetBSD: patch-configure.ac,v 1.1 2022/04/12 22:22:26 nikita Exp $ + +Upstream commit 1acaf9980b55ae180cc08db218b9face28202519 +from Alyssa Ross. + +Use popcount64 from libc when available + +Without this, we get a compiler error on NetBSD because the one in +libc has a slightly different prototype. + +libcpuid_util.c:78:12: error: conflicting types for 'popcount64' + 78 | static int popcount64(uint64_t mask) + | ^~~~~~~~~~ +In file included from /nix/store/155rj8nqh3xd80vpa8hl35p3hk7pacys-include-netbsd-8.0/include/string.h:98, + from libcpuid_util.c:30: +/nix/store/155rj8nqh3xd80vpa8hl35p3hk7pacys-include-netbsd-8.0/include/strings.h:61:14: note: previous declaration of 'popcount64' was here + 61 | unsigned int popcount64(__uint64_t) __constfunc; + | ^~~~~~~~~~ + +* Return unsigned int from popcount64 + +Matches NetBSD libc, where popcount64 originates. + +--- configure.ac.orig ++++ configure.ac +@@ -43,6 +43,8 @@ LT_INIT + AM_CPPFLAGS="$CPPFLAGS" + + AC_CHECK_HEADERS([stdint.h]) ++AC_CHECK_FUNCS([popcount64]) ++ + AC_CHECK_PROGS([DOXYGEN], [doxygen]) + AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"]) + diff --git a/sysutils/libcpuid/patches/patch-libcpuid_libcpuid_util.c b/sysutils/libcpuid/patches/patch-libcpuid_libcpuid_util.c new file mode 100644 index 00000000000..48bd2a4714a --- /dev/null +++ b/sysutils/libcpuid/patches/patch-libcpuid_libcpuid_util.c @@ -0,0 +1,56 @@ +$NetBSD: patch-libcpuid_libcpuid_util.c,v 1.1 2022/04/12 22:22:26 nikita Exp $ + +Upstream commit 1acaf9980b55ae180cc08db218b9face28202519 +from Alyssa Ross. + +Use popcount64 from libc when available + +Without this, we get a compiler error on NetBSD because the one in +libc has a slightly different prototype. + +libcpuid_util.c:78:12: error: conflicting types for 'popcount64' + 78 | static int popcount64(uint64_t mask) + | ^~~~~~~~~~ +In file included from /nix/store/155rj8nqh3xd80vpa8hl35p3hk7pacys-include-netbsd-8.0/include/string.h:98, + from libcpuid_util.c:30: +/nix/store/155rj8nqh3xd80vpa8hl35p3hk7pacys-include-netbsd-8.0/include/strings.h:61:14: note: previous declaration of 'popcount64' was here + 61 | unsigned int popcount64(__uint64_t) __constfunc; + | ^~~~~~~~~~ + +* Return unsigned int from popcount64 + +Matches NetBSD libc, where popcount64 originates. + +--- libcpuid/libcpuid_util.c.orig ++++ libcpuid/libcpuid_util.c +@@ -29,6 +29,9 @@ + #include + #include + #include ++#ifdef HAVE_CONFIG_H ++#include "config.h" ++#endif + #include "libcpuid.h" + #include "libcpuid_util.h" + +@@ -74,9 +77,10 @@ void debugf(int verboselevel, const char* format, ...) + _warn_fun(buff); + } + +-static int popcount64(uint64_t mask) ++#ifndef HAVE_POPCOUNT64 ++static unsigned int popcount64(uint64_t mask) + { +- int num_set_bits = 0; ++ unsigned int num_set_bits = 0; + + while (mask) { + mask &= mask - 1; +@@ -85,6 +89,7 @@ static int popcount64(uint64_t mask) + + return num_set_bits; + } ++#endif + + static int score(const struct match_entry_t* entry, const struct cpu_id_t* data, + int brand_code, uint64_t bits, int model_code) -- cgit v1.2.3