From 2d150278632379feb6dfb238dae32084c5634557 Mon Sep 17 00:00:00 2001 From: Erlend Ese Date: Sun, 18 May 2025 00:41:26 +0200 Subject: [PATCH] Add QNX support by including necessary header for threads and endian functions. Signed-off-by: Erlend Ese --- src/CMakeLists.txt | 1 + src/MQTTPacket.h | 10 +++++++++- src/SHA1.c | 7 +++++++ src/Thread.h | 4 ++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 16382c105..12909cf9b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -80,6 +80,7 @@ elseif(UNIX) set(LIBS_SYSTEM compat pthread) elseif(CMAKE_SYSTEM_NAME MATCHES "QNX") set(LIBS_SYSTEM c) + add_definitions(-D_QNX_SOURCE -DGULLIVER) else() set(LIBS_SYSTEM c pthread) endif() diff --git a/src/MQTTPacket.h b/src/MQTTPacket.h index fd384ae9b..f9a95db50 100644 --- a/src/MQTTPacket.h +++ b/src/MQTTPacket.h @@ -28,7 +28,15 @@ #include "LinkedList.h" #include "Clients.h" -typedef unsigned int bool; +#ifdef __cplusplus + #include +#else + #ifndef __bool_true_false_are_defined + #ifndef bool + typedef unsigned int bool; + #endif + #endif +#endif typedef void* (*pf)(int, unsigned char, char*, size_t); #include "MQTTProperties.h" diff --git a/src/SHA1.c b/src/SHA1.c index 3ef07d920..2e65c41de 100644 --- a/src/SHA1.c +++ b/src/SHA1.c @@ -16,6 +16,13 @@ #include "SHA1.h" +// In the source files using endian functions (like SHA1.c): +#ifdef QNX_OS +#include +#define be32toh(x) ENDIAN_BE32(x) +#define htobe32(x) ENDIAN_BE32(x) +#endif + #if !defined(OPENSSL) #if defined(_WIN32) || defined(_WIN64) #pragma comment(lib, "crypt32.lib") diff --git a/src/Thread.h b/src/Thread.h index b0c823b65..47918fc4e 100644 --- a/src/Thread.h +++ b/src/Thread.h @@ -46,6 +46,10 @@ #undef ETIMEDOUT #define ETIMEDOUT WSAETIMEDOUT #else + #if defined(QNX_OS) + #include + #include + #endif #include #define thread_type pthread_t