From e5ec17fdf6e4071702c99e27512f5e4f5d5fdc34 Mon Sep 17 00:00:00 2001 From: Oscar Lesta Date: Thu, 11 Sep 2025 12:33:27 -0300 Subject: [PATCH] cpuid: new recipe. --- sys-apps/cpuid/cpuid-1.8.3.recipe | 45 ++++++++++++ sys-apps/cpuid/licenses/ISC | 15 ++++ sys-apps/cpuid/patches/cpuid-1.8.3.patchset | 76 +++++++++++++++++++++ 3 files changed, 136 insertions(+) create mode 100644 sys-apps/cpuid/cpuid-1.8.3.recipe create mode 100644 sys-apps/cpuid/licenses/ISC create mode 100644 sys-apps/cpuid/patches/cpuid-1.8.3.patchset diff --git a/sys-apps/cpuid/cpuid-1.8.3.recipe b/sys-apps/cpuid/cpuid-1.8.3.recipe new file mode 100644 index 000000000..ce5732fa0 --- /dev/null +++ b/sys-apps/cpuid/cpuid-1.8.3.recipe @@ -0,0 +1,45 @@ +SUMMARY="Dump and extract information from the x86 CPUID instruction" +DESCRIPTION="cpuid is capable of dumping all CPUID leaves (except any unknown leaves which \ +require special ECX values to dump all information). cpuid can only decode certain leaves, \ +but this functionality will be expanded as the CPUID specifications provided by AMD and Intel \ +change." +HOMEPAGE="https://github.com/tycho/cpuid/" +COPYRIGHT="2010-2025 Steven Noonan" +LICENSE="ISC" +REVISION="1" +SOURCE_URI="https://github.com/tycho/cpuid/archive/refs/tags/$portVersion.tar.gz" +SOURCE_FILENAME="$portBaseName-$portVersion.tar.gz" +CHECKSUM_SHA256="d7edd2771476aab2f56ba950be0b0433dc136fd827507e81d9a68b83adaa1a9a" +PATCHES="$portBaseName-$portVersion.patchset" + +ARCHITECTURES="all !x86_gcc2" +SECONDARY_ARCHITECTURES="x86" + +PROVIDES=" + cpuid$secondaryArchSuffix = $portVersion + cmd:cpuid = $portVersion + " +REQUIRES=" + haiku$secondaryArchSuffix + " + +BUILD_REQUIRES=" + haiku${secondaryArchSuffix}_devel + " +BUILD_PREREQUIRES=" + cmd:gcc$secondaryArchSuffix + cmd:make + cmd:perl + cmd:which + " + +BUILD() +{ + make $jobArgs +} + +INSTALL() +{ + mkdir -p $prefix/bin + cp -a cpuid $prefix/bin +} diff --git a/sys-apps/cpuid/licenses/ISC b/sys-apps/cpuid/licenses/ISC new file mode 100644 index 000000000..471415ff5 --- /dev/null +++ b/sys-apps/cpuid/licenses/ISC @@ -0,0 +1,15 @@ +ISC license + +Copyright (c) 2010-2025, Steven Noonan + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/sys-apps/cpuid/patches/cpuid-1.8.3.patchset b/sys-apps/cpuid/patches/cpuid-1.8.3.patchset new file mode 100644 index 000000000..e6ae424cc --- /dev/null +++ b/sys-apps/cpuid/patches/cpuid-1.8.3.patchset @@ -0,0 +1,76 @@ +From 9c8cad858d712e36468c8925eb3fd5ceb5d7d337 Mon Sep 17 00:00:00 2001 +From: Oscar Lesta +Date: Thu, 11 Sep 2025 12:27:29 -0300 +Subject: Initial Haiku support. + +Built and tested on: + +- Haiku beta5 x86_64 bits. +- Haiku nightly (hrev59030) x86_32 bits. + +On bare-metal, VBox, and under VMware. + +diff --git a/GNUmakefile b/GNUmakefile +index 19f5a04..8215c9a 100644 +--- a/GNUmakefile ++++ b/GNUmakefile +@@ -103,6 +103,10 @@ CFLAGS += -pthread + LDFLAGS += -pthread + endif + ++ifeq ($(uname_S),Haiku) ++LDFLAGS += -lgnu ++endif ++ + ifneq ($(findstring MINGW,$(uname_S))$(findstring MSYS,$(uname_S)),) + LDFLAGS += -lpthread -lwinmm + endif +diff --git a/threads.c b/threads.c +index a42016a..f096b34 100644 +--- a/threads.c ++++ b/threads.c +@@ -49,6 +49,20 @@ + #include + #include + ++#elif defined(TARGET_OS_HAIKU) ++ ++#include ++#include ++ ++#define CPUSET_T cpuset_t ++#define CPUSET_MASK_T cpuset_mask ++ ++#include ++ ++#if (B_HAIKU_VERSION <= B_HAIKU_VERSION_1_BETA_5) ++ #define CPU_ZERO CPUSET_ZERO ++#endif ++ + #elif defined(TARGET_OS_SOLARIS) + #include + #include +@@ -195,7 +209,7 @@ int thread_bind_native(__unused_variable struct cpuid_state_t *state, uint32_t i + + return (ret != FALSE) ? 0 : 1; + +-#elif defined(TARGET_OS_LINUX) || defined(TARGET_OS_FREEBSD) ++#elif defined(TARGET_OS_LINUX) || defined(TARGET_OS_FREEBSD) || defined(TARGET_OS_HAIKU) + + int ret; + +@@ -232,7 +246,11 @@ int thread_bind_native(__unused_variable struct cpuid_state_t *state, uint32_t i + + mask = 1ULL << (unsigned long long)id; + ++#if defined(TARGET_OS_HAIKU) ++ ((unsigned long *)set[set_id].bits)[subset_id] |= mask; ++#else + ((unsigned long *)set[set_id].__bits)[subset_id] |= mask; ++#endif + ret = pthread_setaffinity_np(pth, setsize, set); + free(set); + #endif +-- +2.50.1 +