Add FreeBSD platform support (fixes #156)#158
Conversation
- Add IPC_OS_FREEBSD_ platform detection macro - Enable FreeBSD to use POSIX pthread implementation (shared with QNX) - Update all conditional compilation directives to include FreeBSD - Update README to reflect FreeBSD platform support FreeBSD uses the existing POSIX implementation which supports: - Process-shared mutexes (PTHREAD_PROCESS_SHARED) - Robust mutexes (PTHREAD_MUTEX_ROBUST) - Timed lock operations - POSIX shared memory This is a minimal change that reuses the mature POSIX implementation already proven by QNX platform support.
I have been able to build on FreeBSD with GCC 13.3.0. However, although it builds everything (static library, shared library, demos, and tests) without any errors, unit tests are failing: (And the process seems to stall at that point; I have not debugged it.) Were you expecting any issue? (I'm using a VM to run FreeBSD 14.3, so I'm not sure if that could be the problem.) EDIT: The |
|
The test cases on the current master branch were all refactored by me just last weekend. How about this: I'll first merge this PR into the master branch, and then you can run the unit tests (UT) using the latest master branch to see if they all pass. If any test cases fail, please share them so we can take a look together. |
|
I think that's a good plan. It's definitely an improvement, as it can be built now, and at least some functionality works. (For what it is worth, I had tried this branch also on a Linux system, and unit tests succeed.) |
Summary
This PR adds FreeBSD platform support to cpp-ipc by reusing the existing POSIX pthread implementation.
Changes
IPC_OS_FREEBSD_macro tosrc/libipc/platform/detail.hTechnical Details
FreeBSD uses the existing POSIX implementation (
src/libipc/platform/posix/) which provides:PTHREAD_PROCESS_SHARED)PTHREAD_MUTEX_ROBUST)pthread_mutex_timedlock,pthread_cond_timedwait)shm_open,shm_unlink)Why This Approach?
Testing
The changes are minimal and non-invasive:
Ideally, this should be tested on a FreeBSD system to verify:
Files Modified
README.md- Added FreeBSD to platform listsrc/libipc/platform/detail.h- Added FreeBSD platform detectionsrc/libipc/platform/platform.c- Updated conditional compilationsrc/libipc/platform/platform.cpp- Updated conditional compilationsrc/libipc/sync/condition.cpp- Updated conditional compilationsrc/libipc/sync/mutex.cpp- Updated conditional compilationsrc/libipc/sync/semaphore.cpp- Updated conditional compilationsrc/libipc/sync/waiter.cpp- Updated conditional compilationReferences
Related
Closes #156