cpuid: new recipe.

This commit is contained in:
Oscar Lesta
2025-09-11 12:33:27 -03:00
committed by OscarL
parent d02578c4f5
commit e5ec17fdf6
3 changed files with 136 additions and 0 deletions

View File

@@ -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
}

View File

@@ -0,0 +1,15 @@
ISC license
Copyright (c) 2010-2025, Steven Noonan <steven@uplinklabs.net>
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.

View File

@@ -0,0 +1,76 @@
From 9c8cad858d712e36468c8925eb3fd5ceb5d7d337 Mon Sep 17 00:00:00 2001
From: Oscar Lesta <oscar.lesta@gmail.com>
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 <pthread.h>
#include <sched.h>
+#elif defined(TARGET_OS_HAIKU)
+
+#include <pthread.h>
+#include <sched.h>
+
+#define CPUSET_T cpuset_t
+#define CPUSET_MASK_T cpuset_mask
+
+#include <BeBuild.h>
+
+#if (B_HAIKU_VERSION <= B_HAIKU_VERSION_1_BETA_5)
+ #define CPU_ZERO CPUSET_ZERO
+#endif
+
#elif defined(TARGET_OS_SOLARIS)
#include <string.h>
#include <unistd.h>
@@ -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