Skip to content

Commit b6cbbc9

Browse files
authored
Merge pull request #176 from mutouyun/issue-174
fix: FreeBSD compilation errors (issue #174)
2 parents f7a1812 + 8b1dca8 commit b6cbbc9

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/libipc/platform/posix/condition.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class condition {
9292
}
9393

9494
void clear() noexcept {
95+
LIBIPC_LOG();
9596
if ((shm_.ref() <= 1) && cond_ != nullptr) {
9697
int eno;
9798
if ((eno = ::pthread_cond_destroy(cond_)) != 0) {
@@ -134,6 +135,7 @@ class condition {
134135
}
135136

136137
bool notify(ipc::sync::mutex &) noexcept {
138+
LIBIPC_LOG();
137139
if (!valid()) return false;
138140
int eno;
139141
if ((eno = ::pthread_cond_signal(cond_)) != 0) {
@@ -144,6 +146,7 @@ class condition {
144146
}
145147

146148
bool broadcast(ipc::sync::mutex &) noexcept {
149+
LIBIPC_LOG();
147150
if (!valid()) return false;
148151
int eno;
149152
if ((eno = ::pthread_cond_broadcast(cond_)) != 0) {

src/libipc/platform/posix/mutex.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ class mutex {
113113
}
114114

115115
bool open(char const *name) noexcept {
116+
LIBIPC_LOG();
116117
close();
117118
if ((mutex_ = acquire_mutex(name)) == nullptr) {
118119
return false;
@@ -152,7 +153,7 @@ class mutex {
152153
LIBIPC_LOG();
153154
if ((ref_ != nullptr) && (shm_ != nullptr) && (mutex_ != nullptr)) {
154155
if (shm_->name() != nullptr) {
155-
release_mutex(shm_->name(), [this] {
156+
release_mutex(shm_->name(), [this, &log] {
156157
auto self_ref = ref_->fetch_sub(1, std::memory_order_relaxed);
157158
if ((shm_->ref() <= 1) && (self_ref <= 1)) {
158159
// Before destroying the mutex, try to unlock it.
@@ -183,7 +184,7 @@ class mutex {
183184
LIBIPC_LOG();
184185
if ((shm_ != nullptr) && (mutex_ != nullptr)) {
185186
if (shm_->name() != nullptr) {
186-
release_mutex(shm_->name(), [this] {
187+
release_mutex(shm_->name(), [this, &log] {
187188
// Unlock before destroying, same reasoning as in close()
188189
::pthread_mutex_unlock(mutex_);
189190

@@ -240,6 +241,7 @@ class mutex {
240241
}
241242

242243
bool try_lock() noexcept(false) {
244+
LIBIPC_LOG();
243245
if (!valid()) return false;
244246
auto ts = posix_::detail::make_timespec(0);
245247
int eno = ::pthread_mutex_timedlock(mutex_, &ts);

src/libipc/sync/semaphore.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
#include "libipc/platform/detail.h"
88
#if defined(LIBIPC_OS_WIN)
99
#include "libipc/platform/win/semaphore.h"
10-
#elif defined(LIBIPC_OS_QNX) || defined(LIBIPC_OS_FREEBSD)
11-
#elif defined(LIBIPC_OS_LINUX) || defined(LIBIPC_OS_QNX)
10+
#elif defined(LIBIPC_OS_LINUX) || defined(LIBIPC_OS_QNX) || defined(LIBIPC_OS_FREEBSD)
1211
#include "libipc/platform/posix/semaphore_impl.h"
1312
#else/*IPC_OS*/
1413
# error "Unsupported platform."

0 commit comments

Comments
 (0)