Skip to content

Commit

Permalink
cmake, thread: OpenBSD support (#773)
Browse files Browse the repository at this point in the history
* build brt.c on OpenBSD

* include <sys/types.h> 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
  • Loading branch information
landryb authored Apr 28, 2023
1 parent 36e19ed commit 46e3706
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmake/re-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 7 additions & 0 deletions src/thread/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#endif
#ifdef HAVE_PTHREAD
#include <pthread.h>
#ifdef OPENBSD
#include <pthread_np.h>
#endif
#endif


Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 46e3706

Please sign in to comment.