From 2ab97ea22c93ab45511100dc5cb20534dab0c9ab Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Wed, 15 Jan 2025 14:17:01 -0500 Subject: [PATCH] Re-introduce NetBSD support [ History added by Mathieu Desnoyers: commit bd252a04bbbb ("Use urcu/tls-compat.h") introduce support for OpenBSD, NetBSD and Darwin by using tls-compat.h in across urcu. (v0.7.0) commit 9ba261bd496f ("Android: add a compat layer for 'syscall.h'") added a syscall compatibility layer for Android. (v0.9.0) commit b10602e3b143 ("Port: Add Solaris support to urcu/syscall-compat.h") added Solaris support to urcu/syscall-compat.h (v0.9.0), and doing so added a: #else #error "Add platform support to urcu/syscall-compat.h" preventing build to succeed on unlisted platforms. Before that commit, unlisted platforms would rely on fallback implementations for urcu_get_thread_id() (getpid()), futex_async() (busy-wait with poll(2) delay), and futex_noasync() (pthread_cond(3)). The choice was made at this point to fail build on OSes that were not tested against in order to allow consideration of better suited implementations for urcu_get_thread_id(), futex_async(), and futex_noasync(), and ensure a minimum level of testing. commit 80a92637ed8c ("Add FreeBSD, DragonFly to syscall-compat.h") re-introduce support for FreeBSD and DragonFly (v0.12.0). commit 020351f306d4 ("Add support for OpenBSD") re-introduced OpenBSD support implementing urcu_get_thread_id() with getthrid() (v0.13.4). ] regtest.out: ============================================================================ Testsuite summary for userspace-rcu 0.15.0 ============================================================================ TOTAL: 852 PASS: 852 SKIP: 0 XFAIL: 0 FAIL: 0 XPASS: 0 ERROR: 0 ============================================================================ TIME=38:58.39 CPU=597.9% (13605.556u 375.860s) SWAPS=0 (157727+3641680)pf (0i+338o) (1Kc+32Kd) short_bench.out: ============================================================================ Testsuite summary for userspace-rcu 0.15.0 ============================================================================ TOTAL: 852 PASS: 852 SKIP: 0 XFAIL: 0 FAIL: 0 XPASS: 0 ERROR: 0 ============================================================================ TIME=1:02:33.91 CPU=716.0% (26438.855u 439.871s) SWAPS=0 (166007+2996145)pf (0i+353o) (0Kc+9Kd) Signed-off-by: Christos Zoulas Tested-by: Christos Zoulas Signed-off-by: Mathieu Desnoyers Change-Id: I0dbefff0c9f1cbf31741864748ff9b46bd4dd537 --- include/urcu/syscall-compat.h | 2 +- tests/common/thread-id.h | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/urcu/syscall-compat.h b/include/urcu/syscall-compat.h index d49b988..51f3bd6 100644 --- a/include/urcu/syscall-compat.h +++ b/include/urcu/syscall-compat.h @@ -16,7 +16,7 @@ #elif defined(__CYGWIN__) || defined(__APPLE__) || \ defined(__FreeBSD__) || defined(__DragonFly__) || \ - defined(__OpenBSD__) + defined(__OpenBSD__) || defined(__NetBSD__) /* Don't include anything on these platforms. */ #else diff --git a/tests/common/thread-id.h b/tests/common/thread-id.h index 575acaf..2ee0fd4 100644 --- a/tests/common/thread-id.h +++ b/tests/common/thread-id.h @@ -67,6 +67,14 @@ unsigned long urcu_get_thread_id(void) { return (unsigned long) getthrid(); } +#elif defined(__NetBSD__) +#include + +static inline +unsigned long urcu_get_thread_id(void) +{ + return (unsigned long) _lwp_self(); +} #else # warning "use pid as thread ID" static inline -- 2.39.5