From 9ac5c242546bb33ba2b570d4cf310621f529aed7 Mon Sep 17 00:00:00 2001 From: mutouyun Date: Thu, 29 Jan 2026 03:20:25 +0000 Subject: [PATCH 1/2] fix(freebsd): include semaphore_impl.h for FreeBSD platform Fix issue #174: FreeBSD was excluded from including the POSIX semaphore implementation header. The previous conditional compilation had an empty branch for LIBIPC_OS_FREEBSD, causing 'no member named sync in namespace ipc::detail' errors. FreeBSD supports POSIX semaphore APIs (sem_open, sem_wait, sem_post, etc.), so it should use the same semaphore_impl.h as Linux and QNX. --- src/libipc/sync/semaphore.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libipc/sync/semaphore.cpp b/src/libipc/sync/semaphore.cpp index 8f1dbb7..bf09f04 100644 --- a/src/libipc/sync/semaphore.cpp +++ b/src/libipc/sync/semaphore.cpp @@ -7,8 +7,7 @@ #include "libipc/platform/detail.h" #if defined(LIBIPC_OS_WIN) #include "libipc/platform/win/semaphore.h" -#elif defined(LIBIPC_OS_QNX) || defined(LIBIPC_OS_FREEBSD) -#elif defined(LIBIPC_OS_LINUX) || defined(LIBIPC_OS_QNX) +#elif defined(LIBIPC_OS_LINUX) || defined(LIBIPC_OS_QNX) || defined(LIBIPC_OS_FREEBSD) #include "libipc/platform/posix/semaphore_impl.h" #else/*IPC_OS*/ # error "Unsupported platform." From 8b1dca8831c245845cb06f0307ea8812a72f1b60 Mon Sep 17 00:00:00 2001 From: mutouyun Date: Thu, 29 Jan 2026 03:21:03 +0000 Subject: [PATCH 2/2] fix(posix): add missing LIBIPC_LOG() calls and fix lambda captures Fix issue #174: Several functions in mutex.h and condition.h were using the 'log' variable without first calling LIBIPC_LOG() macro, which defines the 'log' variable. This caused FreeBSD compiler errors like 'unexpected namespace name log: expected expression'. Changes in mutex.h: - Add LIBIPC_LOG() at the beginning of open() - Add LIBIPC_LOG() at the beginning of try_lock() - Fix lambda capture in close() to include '&log' - Fix lambda capture in clear() to include '&log' Changes in condition.h: - Add LIBIPC_LOG() at the beginning of clear() - Add LIBIPC_LOG() at the beginning of notify() - Add LIBIPC_LOG() at the beginning of broadcast() --- src/libipc/platform/posix/condition.h | 3 +++ src/libipc/platform/posix/mutex.h | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/libipc/platform/posix/condition.h b/src/libipc/platform/posix/condition.h index ea66a96..77ff56f 100644 --- a/src/libipc/platform/posix/condition.h +++ b/src/libipc/platform/posix/condition.h @@ -92,6 +92,7 @@ public: } void clear() noexcept { + LIBIPC_LOG(); if ((shm_.ref() <= 1) && cond_ != nullptr) { int eno; if ((eno = ::pthread_cond_destroy(cond_)) != 0) { @@ -134,6 +135,7 @@ public: } bool notify(ipc::sync::mutex &) noexcept { + LIBIPC_LOG(); if (!valid()) return false; int eno; if ((eno = ::pthread_cond_signal(cond_)) != 0) { @@ -144,6 +146,7 @@ public: } bool broadcast(ipc::sync::mutex &) noexcept { + LIBIPC_LOG(); if (!valid()) return false; int eno; if ((eno = ::pthread_cond_broadcast(cond_)) != 0) { diff --git a/src/libipc/platform/posix/mutex.h b/src/libipc/platform/posix/mutex.h index 16f2647..a4c5e9f 100644 --- a/src/libipc/platform/posix/mutex.h +++ b/src/libipc/platform/posix/mutex.h @@ -113,6 +113,7 @@ public: } bool open(char const *name) noexcept { + LIBIPC_LOG(); close(); if ((mutex_ = acquire_mutex(name)) == nullptr) { return false; @@ -152,7 +153,7 @@ public: LIBIPC_LOG(); if ((ref_ != nullptr) && (shm_ != nullptr) && (mutex_ != nullptr)) { if (shm_->name() != nullptr) { - release_mutex(shm_->name(), [this] { + release_mutex(shm_->name(), [this, &log] { auto self_ref = ref_->fetch_sub(1, std::memory_order_relaxed); if ((shm_->ref() <= 1) && (self_ref <= 1)) { // Before destroying the mutex, try to unlock it. @@ -183,7 +184,7 @@ public: LIBIPC_LOG(); if ((shm_ != nullptr) && (mutex_ != nullptr)) { if (shm_->name() != nullptr) { - release_mutex(shm_->name(), [this] { + release_mutex(shm_->name(), [this, &log] { // Unlock before destroying, same reasoning as in close() ::pthread_mutex_unlock(mutex_); @@ -240,6 +241,7 @@ public: } bool try_lock() noexcept(false) { + LIBIPC_LOG(); if (!valid()) return false; auto ts = posix_::detail::make_timespec(0); int eno = ::pthread_mutex_timedlock(mutex_, &ts);