Fix mstp on bsd port (#1193)

* fix mstp on macos NS_PER_S is 1s and 0ns

* fix compile on freebsd

* port bsd: add compile warnings and comments

* port bsd: limit pthred prio to OS defined min/max value
e.g. FreeBSD min=0 max=31

* port bsd: fix clangformat
This commit is contained in:
Patrick Grimm
2025-12-25 01:50:29 +01:00
committed by GitHub
parent 88abd3a488
commit 2f6132b13e
5 changed files with 332 additions and 241 deletions
+25
View File
@@ -159,6 +159,17 @@ if (CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "AppleCla
add_compile_options(-Wno-long-long)
endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
# These warnings orginate from libdispatch
# ISO C restricts enumerator values to range of 'int'
# DISPATCH_ENUM_API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) = ~1ull
add_compile_options(-Wno-pedantic)
# These warnings originate from libdispatch headers,
# which rely on Clang extensions that Apple Clang supports,
# but FreeBSD LLVM Clang does not.
add_compile_options(-Wno-nullability-extension)
endif()
# Should be fixed in a future.
add_compile_options(-Wno-cast-qual)
add_compile_options(-Wno-double-promotion)
@@ -839,6 +850,7 @@ elseif(APPLE)
message(STATUS "BACNET: building for APPLE")
set(BACNET_PORT_DIRECTORY_PATH ${CMAKE_CURRENT_LIST_DIR}/ports/bsd)
add_compile_definitions(BACNET_PORT=bsd)
add_compile_definitions(USE_MACH_TIME)
include_directories(ports/posix)
target_sources(${PROJECT_NAME} PRIVATE
@@ -884,6 +896,18 @@ elseif(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
message(STATUS "BACNET: building for FreeBSD")
set(BACNET_PORT_DIRECTORY_PATH ${CMAKE_CURRENT_LIST_DIR}/ports/bsd)
include_directories(ports/posix)
link_directories(/usr/lib)
link_libraries(c)
link_libraries(m)
FIND_PATH(DISPATCH_INCLUDE dispatch/dispatch.h)
FIND_LIBRARY(DISPATCH_LIBRARIES NAMES dispatch)
if(NOT DISPATCH_INCLUDE OR NOT DISPATCH_LIBRARIES)
message(FATAL_ERROR "BACNET: dispatch.h header file not found
install libdispatch with 'pkg install libdispatch'")
else()
include_directories(${DISPATCH_INCLUDE})
link_libraries(${DISPATCH_LIBRARIES})
endif()
target_sources(${PROJECT_NAME} PRIVATE
ports/bsd/bacport.h
@@ -1091,6 +1115,7 @@ if(BACNET_STACK_BUILD_APPS)
if(NOT LIBCONFIG_LIBRARIES)
message(WARNING "BACNET: Will not build apps/router as libconfig not found")
else()
message(STATUS "BACNET: Will build apps/router with libconfig")
add_executable(
router
${BACNET_PORT_DIRECTORY_PATH}/dlmstp_port.c