From 30a0150d81d9f5b3b7e8ed2c436e0c8eba9995b2 Mon Sep 17 00:00:00 2001 From: c0dev0id Date: Mon, 19 Dec 2022 01:56:07 +0100 Subject: [PATCH] Add cpuid-tycho --- sysutils/cpuid-tycho/Makefile | 28 +++++++++++++ sysutils/cpuid-tycho/distinfo | 2 + .../cpuid-tycho/patches/patch-GNUmakefile | 16 ++++++++ sysutils/cpuid-tycho/patches/patch-threads_c | 41 +++++++++++++++++++ .../cpuid-tycho/patches/patch-threads_c.orig | 40 ++++++++++++++++++ sysutils/cpuid-tycho/pkg/DESCR | 7 ++++ sysutils/cpuid-tycho/pkg/PLIST | 2 + 7 files changed, 136 insertions(+) create mode 100644 sysutils/cpuid-tycho/Makefile create mode 100644 sysutils/cpuid-tycho/distinfo create mode 100644 sysutils/cpuid-tycho/patches/patch-GNUmakefile create mode 100644 sysutils/cpuid-tycho/patches/patch-threads_c create mode 100644 sysutils/cpuid-tycho/patches/patch-threads_c.orig create mode 100644 sysutils/cpuid-tycho/pkg/DESCR create mode 100644 sysutils/cpuid-tycho/pkg/PLIST diff --git a/sysutils/cpuid-tycho/Makefile b/sysutils/cpuid-tycho/Makefile new file mode 100644 index 0000000..a4c89c9 --- /dev/null +++ b/sysutils/cpuid-tycho/Makefile @@ -0,0 +1,28 @@ +# $OpenBSD$ + +ONLY_FOR_ARCHS= i386 amd64 + +COMMENT= dump and decode x86 CPUID information + +GH_ACCOUNT= tycho +GH_PROJECT= cpuid +GH_TAGNAME= 1.8.2 + +PKGNAME= cpuid-tycho-${GH_TAGNAME} + +CATEGORIES= sysutils + +MAINTAINER= Stuart Henderson + +# ISC +PERMIT_PACKAGE= Yes + +WANTLIB += c m pthread + +MODULES= devel/meson +NO_TEST= Yes + +do-install: + ${INSTALL_PROGRAM} ${WRKBUILD}/cpuid ${PREFIX}/bin/cpuid-tycho + +.include diff --git a/sysutils/cpuid-tycho/distinfo b/sysutils/cpuid-tycho/distinfo new file mode 100644 index 0000000..313d702 --- /dev/null +++ b/sysutils/cpuid-tycho/distinfo @@ -0,0 +1,2 @@ +SHA256 (cpuid-1.8.2.tar.gz) = NJR/RIQlJ0XprIIZFr0ANJwng23vTeJicv9uLHjr1OU= +SIZE (cpuid-1.8.2.tar.gz) = 63055 diff --git a/sysutils/cpuid-tycho/patches/patch-GNUmakefile b/sysutils/cpuid-tycho/patches/patch-GNUmakefile new file mode 100644 index 0000000..3ab19ce --- /dev/null +++ b/sysutils/cpuid-tycho/patches/patch-GNUmakefile @@ -0,0 +1,16 @@ +$OpenBSD$ +Index: GNUmakefile +--- GNUmakefile.orig ++++ GNUmakefile +@@ -7,6 +7,11 @@ uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo + prefix := /usr/local + bindir := $(prefix)/bin + ++ifeq ($(uname_S),OpenBSD) ++CFLAGS += -pthread ++LDFLAGS += -pthread ++endif ++ + ifneq ($(findstring MINGW,$(uname_S)),) + win32 = Yep + endif diff --git a/sysutils/cpuid-tycho/patches/patch-threads_c b/sysutils/cpuid-tycho/patches/patch-threads_c new file mode 100644 index 0000000..f9a01bc --- /dev/null +++ b/sysutils/cpuid-tycho/patches/patch-threads_c @@ -0,0 +1,41 @@ +$OpenBSD$ + +Index: threads.c +--- threads.c.orig ++++ threads.c +@@ -49,13 +49,15 @@ + #include + #include + +-#elif defined(TARGET_OS_SOLARIS) ++#elif defined(TARGET_OS_SOLARIS) || defined(TARGET_OS_OPENBSD) + #include + #include + #include + #include ++#if defined(TARGET_OS_SOLARIS) + #include + #include ++#endif + + + #elif defined(TARGET_OS_MACOSX) +@@ -116,7 +118,7 @@ uint32_t thread_count_native(struct cpuid_state_t *sta + return 1; + + return count; +-#elif defined(TARGET_OS_SOLARIS) ++#elif defined(TARGET_OS_SOLARIS) || defined(TARGET_OS_OPENBSD) + long count; + + if ((count = sysconf(_SC_NPROCESSORS_ONLN)) == -1) +@@ -289,7 +291,8 @@ int thread_bind_native(__unused_variable struct cpuid_ + + return ret == 0 ? 0 : 1; + #else +-#error "thread_bind_native() not defined for this platform" ++#warning "thread_bind_native() not defined for this platform" ++ return 0; + #endif + } + diff --git a/sysutils/cpuid-tycho/patches/patch-threads_c.orig b/sysutils/cpuid-tycho/patches/patch-threads_c.orig new file mode 100644 index 0000000..3ce74bf --- /dev/null +++ b/sysutils/cpuid-tycho/patches/patch-threads_c.orig @@ -0,0 +1,40 @@ +$OpenBSD$ +Index: threads.c +--- threads.c.orig ++++ threads.c +@@ -44,13 +44,15 @@ + #undef MAX_CPUS + #define MAX_CPUS CPU_MAXSIZE + +-#elif defined(TARGET_OS_SOLARIS) ++#elif defined(TARGET_OS_SOLARIS) || defined(TARGET_OS_OPENBSD) + #include + #include + #include + #include ++#if defined(TARGET_OS_SOLARIS) + #include + #include ++#endif + + + #elif defined(TARGET_OS_MACOSX) +@@ -111,7 +113,7 @@ uint32_t thread_count_native(struct cpuid_state_t *sta + return 1; + + return count; +-#elif defined(TARGET_OS_SOLARIS) ++#elif defined(TARGET_OS_SOLARIS) || defined(TARGET_OS_OPENBSD) + long count; + + if ((count = sysconf(_SC_NPROCESSORS_ONLN)) == -1) +@@ -263,7 +265,8 @@ int thread_bind_native(__unused_variable struct cpuid_ + + return ret == 0 ? 0 : 1; + #else +-#error "thread_bind_native() not defined for this platform" ++#warning "thread_bind_native() not defined for this platform" ++ return 0; + #endif + } + diff --git a/sysutils/cpuid-tycho/pkg/DESCR b/sysutils/cpuid-tycho/pkg/DESCR new file mode 100644 index 0000000..84b9371 --- /dev/null +++ b/sysutils/cpuid-tycho/pkg/DESCR @@ -0,0 +1,7 @@ +"cpuid" dumps results from the x86 CPUID instruction, and decodes +information from certain leaves. + +NOTE: the code in this software to bind to a specific CPU is non functional +on OpenBSD; if you are trying to find information from different cores, you'll +need to run it multiple times until the process is scheduled on the core of +interest. diff --git a/sysutils/cpuid-tycho/pkg/PLIST b/sysutils/cpuid-tycho/pkg/PLIST new file mode 100644 index 0000000..2bcd705 --- /dev/null +++ b/sysutils/cpuid-tycho/pkg/PLIST @@ -0,0 +1,2 @@ +@comment $OpenBSD: PLIST,v$ +@bin bin/cpuid-tycho