From 20c79e32f8aed496f5c9dad433cacdca18aed4cf Mon Sep 17 00:00:00 2001 From: Charlotte Koch Date: Thu, 24 Oct 2024 15:42:26 -0700 Subject: [PATCH] Add preliminary support for NetBSD --- source/CMakeLists.txt | 8 ++++++++ source/core/StarThread_unix.cpp | 2 ++ 2 files changed, 10 insertions(+) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index d13d59d..59fa0a6 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -80,6 +80,8 @@ if(NOT DEFINED STAR_SYSTEM) set(STAR_SYSTEM "linux") elseif(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") set(STAR_SYSTEM "freebsd") + elseif(${CMAKE_SYSTEM_NAME} STREQUAL "NetBSD") + set(STAR_SYSTEM "netbsd") elseif(UNIX) set(STAR_SYSTEM "unix") else() @@ -208,6 +210,8 @@ elseif(STAR_SYSTEM STREQUAL "linux") set_flag(STAR_SYSTEM_LINUX) elseif(STAR_SYSTEM STREQUAL "freebsd") set_flag(STAR_SYSTEM_FREEBSD) +elseif(STAR_SYSTEM STREQUAL "netbsd") + set_flag(STAR_SYSTEM_NETBSD) endif() if(STAR_SYSTEM_FAMILY STREQUAL "windows") @@ -445,6 +449,10 @@ elseif(STAR_SYSTEM_FREEBSD) set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lpthread -lrt") set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lpthread -lrt") +elseif(STAR_SYSTEM_NETBSD) + set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lpthread -lrt -lexecinfo") + set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lpthread -lrt -lexecinfo") + endif() # Find all required external libraries, based on build settings... diff --git a/source/core/StarThread_unix.cpp b/source/core/StarThread_unix.cpp index 7385ae2..fe82ea3 100644 --- a/source/core/StarThread_unix.cpp +++ b/source/core/StarThread_unix.cpp @@ -78,6 +78,8 @@ struct ThreadImpl { #ifdef STAR_SYSTEM_FREEBSD pthread_set_name_np(pthread, tname); +#elif defined(STAR_SYSTEM_NETBSD) + pthread_setname_np(pthread, "%s", tname); #elif not defined STAR_SYSTEM_MACOS pthread_setname_np(pthread, tname); #endif