From bc9e135d6f3bfa81b44b17ec5d90c7836d09d35d Mon Sep 17 00:00:00 2001 From: Richard Allen Date: Tue, 5 Nov 2024 18:43:34 -0600 Subject: [PATCH] AP_HAL_SITL: support port SITL to OpenBSD --- libraries/AP_HAL_SITL/Scheduler.cpp | 4 ++-- libraries/AP_HAL_SITL/UARTDriver.cpp | 2 ++ libraries/AP_HAL_SITL/UART_utils.cpp | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libraries/AP_HAL_SITL/Scheduler.cpp b/libraries/AP_HAL_SITL/Scheduler.cpp index d9a2a3ba3a..ccc40042e8 100644 --- a/libraries/AP_HAL_SITL/Scheduler.cpp +++ b/libraries/AP_HAL_SITL/Scheduler.cpp @@ -7,7 +7,7 @@ #include #include #include -#if defined (__clang__) || (defined (__APPLE__) && defined (__MACH__)) +#if defined (__clang__) || (defined (__APPLE__) && defined (__MACH__)) || defined (__OpenBSD__) #include #else #include @@ -385,7 +385,7 @@ bool Scheduler::thread_create(AP_HAL::MemberProc proc, const char *name, uint32_ goto failed; } -#if !defined(__APPLE__) +#if !defined(__APPLE__) && !defined(__OpenBSD__) pthread_setname_np(thread, name); #endif diff --git a/libraries/AP_HAL_SITL/UARTDriver.cpp b/libraries/AP_HAL_SITL/UARTDriver.cpp index 39738637e0..e809f4a43b 100644 --- a/libraries/AP_HAL_SITL/UARTDriver.cpp +++ b/libraries/AP_HAL_SITL/UARTDriver.cpp @@ -714,6 +714,8 @@ bool UARTDriver::set_unbuffered_writes(bool on) { v &= ~O_NONBLOCK; #if defined(__APPLE__) && defined(__MACH__) fcntl(_fd, F_SETFL | F_NOCACHE, v | O_SYNC); +#elif defined(__OpenBSD__) + fcntl(_fd, F_SETFL, v | O_SYNC); #else fcntl(_fd, F_SETFL, v | O_DIRECT | O_SYNC); #endif diff --git a/libraries/AP_HAL_SITL/UART_utils.cpp b/libraries/AP_HAL_SITL/UART_utils.cpp index a3dfcccc28..ca4628c57b 100644 --- a/libraries/AP_HAL_SITL/UART_utils.cpp +++ b/libraries/AP_HAL_SITL/UART_utils.cpp @@ -19,7 +19,7 @@ #include "UARTDriver.h" -#if defined(__CYGWIN__) || defined(__CYGWIN64__) || defined(__APPLE__) +#if defined(__CYGWIN__) || defined(__CYGWIN64__) || defined(__APPLE__) || defined(__OpenBSD__) #define USE_TERMIOS #endif