From 46e3706dc71dee94f300751be55b6f5c20f2966f Mon Sep 17 00:00:00 2001 From: Landry Breuil Date: Fri, 28 Apr 2023 08:47:12 +0200 Subject: [PATCH] cmake, thread: OpenBSD support (#773) * build brt.c on OpenBSD * include to properly detect kqueue() on OpenBSD per http://man.openbsd.org/kqueue.2, otherwise kqueue() detection fails * use the proper pthread_set_name_np() on OpenBSD --- CMakeLists.txt | 4 ++++ cmake/re-config.cmake | 2 +- src/thread/thread.c | 7 +++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7430ec7e8..a415de5e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -586,6 +586,10 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") list(APPEND SRCS src/net/bsd/brt.c ) +elseif(${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") + list(APPEND SRCS + src/net/bsd/brt.c + ) elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") list(APPEND SRCS src/net/linux/rt.c diff --git a/cmake/re-config.cmake b/cmake/re-config.cmake index 6443bcdf1..4f65a9623 100644 --- a/cmake/re-config.cmake +++ b/cmake/re-config.cmake @@ -73,7 +73,7 @@ if(UNIX) if(HAVE_EPOLL) list(APPEND RE_DEFINITIONS -DHAVE_EPOLL) endif() - check_symbol_exists(kqueue "sys/event.h" HAVE_KQUEUE) + check_symbol_exists(kqueue "sys/types.h;sys/event.h" HAVE_KQUEUE) if(HAVE_KQUEUE) list(APPEND RE_DEFINITIONS -DHAVE_KQUEUE) endif() diff --git a/src/thread/thread.c b/src/thread/thread.c index ba9be9b11..7e980c584 100644 --- a/src/thread/thread.c +++ b/src/thread/thread.c @@ -14,6 +14,9 @@ #endif #ifdef HAVE_PTHREAD #include +#ifdef OPENBSD +#include +#endif #endif @@ -74,7 +77,11 @@ static int handler(void *p) #elif defined(DARWIN) (void)pthread_setname_np(th.name); #elif defined(HAVE_PTHREAD) +#if defined(OPENBSD) + (void)pthread_set_name_np(*th.thr, th.name); +#else (void)pthread_setname_np(*th.thr, th.name); +#endif #endif return th.func(th.arg);