AP_Networking: fix for linux build

This commit is contained in:
Andrew Tridgell 2023-12-26 13:41:28 +11:00
parent 985816ebc2
commit 7e29452082
2 changed files with 10 additions and 8 deletions

View File

@ -6,7 +6,7 @@
#endif #endif
#ifndef AP_NETWORKING_ENABLED #ifndef AP_NETWORKING_ENABLED
#define AP_NETWORKING_ENABLED 0 #define AP_NETWORKING_ENABLED ((CONFIG_HAL_BOARD == HAL_BOARD_LINUX) || (CONFIG_HAL_BOARD == HAL_BOARD_SITL))
#endif #endif
#ifndef AP_NETWORKING_BACKEND_DEFAULT_ENABLED #ifndef AP_NETWORKING_BACKEND_DEFAULT_ENABLED
@ -40,7 +40,9 @@
#define AP_NETWORKING_BACKEND_SITL (AP_NETWORKING_BACKEND_DEFAULT_ENABLED && (CONFIG_HAL_BOARD == HAL_BOARD_SITL)) #define AP_NETWORKING_BACKEND_SITL (AP_NETWORKING_BACKEND_DEFAULT_ENABLED && (CONFIG_HAL_BOARD == HAL_BOARD_SITL))
#endif #endif
#ifndef AP_NETWORKING_SOCKETS_ENABLED
#define AP_NETWORKING_SOCKETS_ENABLED AP_NETWORKING_ENABLED #define AP_NETWORKING_SOCKETS_ENABLED AP_NETWORKING_ENABLED
#endif
// --------------------------- // ---------------------------
// IP Features // IP Features

View File

@ -26,7 +26,7 @@ extern "C" {
#include "lwip/tcpip.h" #include "lwip/tcpip.h"
} }
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL #if CONFIG_HAL_BOARD == HAL_BOARD_SITL || CONFIG_HAL_BOARD == HAL_BOARD_LINUX
#include <semaphore.h> #include <semaphore.h>
#elif CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS #elif CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
#include "hal.h" #include "hal.h"
@ -61,7 +61,7 @@ struct sys_mbox {
}; };
struct sys_sem { struct sys_sem {
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL #if CONFIG_HAL_BOARD == HAL_BOARD_SITL || CONFIG_HAL_BOARD == HAL_BOARD_LINUX
sem_t sem; sem_t sem;
#elif CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS #elif CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
semaphore_t sem; semaphore_t sem;
@ -80,7 +80,7 @@ struct thread_wrapper_data {
void *arg; void *arg;
}; };
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL #if CONFIG_HAL_BOARD == HAL_BOARD_SITL || CONFIG_HAL_BOARD == HAL_BOARD_LINUX
static void * static void *
thread_wrapper(void *arg) thread_wrapper(void *arg)
{ {
@ -107,7 +107,7 @@ sys_thread_new(const char *name, lwip_thread_fn function, void *arg, int stacksi
thread_data->arg = arg; thread_data->arg = arg;
thread_data->function = function; thread_data->function = function;
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL #if CONFIG_HAL_BOARD == HAL_BOARD_SITL || CONFIG_HAL_BOARD == HAL_BOARD_LINUX
pthread_t t; pthread_t t;
if (pthread_create(&t, NULL, thread_wrapper, thread_data) == 0) { if (pthread_create(&t, NULL, thread_wrapper, thread_data) == 0) {
pthread_setname_np(t, name); pthread_setname_np(t, name);
@ -346,7 +346,7 @@ sys_sem_new_internal(u8_t count)
{ {
auto *ret = new sys_sem; auto *ret = new sys_sem;
if (ret != nullptr) { if (ret != nullptr) {
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL #if CONFIG_HAL_BOARD == HAL_BOARD_SITL || CONFIG_HAL_BOARD == HAL_BOARD_LINUX
sem_init(&ret->sem, 0, count); sem_init(&ret->sem, 0, count);
#elif CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS #elif CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
chSemObjectInit(&ret->sem, (cnt_t)count); chSemObjectInit(&ret->sem, (cnt_t)count);
@ -369,7 +369,7 @@ u32_t
sys_arch_sem_wait(struct sys_sem **s, u32_t timeout_ms) sys_arch_sem_wait(struct sys_sem **s, u32_t timeout_ms)
{ {
struct sys_sem *sem = *s; struct sys_sem *sem = *s;
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL #if CONFIG_HAL_BOARD == HAL_BOARD_SITL || CONFIG_HAL_BOARD == HAL_BOARD_LINUX
if (timeout_ms == 0) { if (timeout_ms == 0) {
sem_wait(&sem->sem); sem_wait(&sem->sem);
return 0; return 0;
@ -404,7 +404,7 @@ void
sys_sem_signal(struct sys_sem **s) sys_sem_signal(struct sys_sem **s)
{ {
struct sys_sem *sem = *s; struct sys_sem *sem = *s;
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL #if CONFIG_HAL_BOARD == HAL_BOARD_SITL || CONFIG_HAL_BOARD == HAL_BOARD_LINUX
sem_post(&sem->sem); sem_post(&sem->sem);
#elif CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS #elif CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
chSemSignal(&sem->sem); chSemSignal(&sem->sem);