Files
haikuports/sys-apps/cpuid/patches/cpuid-1.8.3.patchset

101 lines
2.3 KiB
Plaintext

From 6224b7667657c85e8cfa063fa01560979b33a680 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
From 4280df389f88c70244be76fbeecc88685804eab0 Mon Sep 17 00:00:00 2001
From: Oscar Lesta <oscar.lesta@gmail.com>
Date: Sun, 14 Sep 2025 19:28:00 -0300
Subject: Try to fix the build on builders using older beta5.
diff --git a/threads.c b/threads.c
index f096b34..7386615 100644
--- a/threads.c
+++ b/threads.c
@@ -51,6 +51,9 @@
#elif defined(TARGET_OS_HAIKU)
+// only needed on current builder bots, still running hrev57937_111
+#define _GNU_SOURCE
+
#include <pthread.h>
#include <sched.h>
--
2.50.1