Skip to content

Conversation

@mutouyun
Copy link
Owner

Summary

This PR adds FreeBSD platform support to cpp-ipc by reusing the existing POSIX pthread implementation.

Changes

  • Platform Detection: Added IPC_OS_FREEBSD_ macro to src/libipc/platform/detail.h
  • Conditional Compilation: Updated all sync modules to include FreeBSD alongside QNX for POSIX implementation
  • Documentation: Updated README.md to reflect FreeBSD platform support

Technical Details

FreeBSD uses the existing POSIX implementation (src/libipc/platform/posix/) which provides:

  • Process-shared mutexes (PTHREAD_PROCESS_SHARED)
  • Robust mutexes (PTHREAD_MUTEX_ROBUST)
  • Timed lock operations (pthread_mutex_timedlock, pthread_cond_timedwait)
  • POSIX shared memory (shm_open, shm_unlink)

Why This Approach?

  1. Minimal Changes: Only 8 files modified, 10 lines of code changed
  2. Low Risk: Reuses mature POSIX implementation already proven by QNX platform
  3. Complete Functionality: FreeBSD's POSIX implementation fully supports all required features
  4. Easy Maintenance: FreeBSD and QNX share the same implementation

Testing

The changes are minimal and non-invasive:

  • No changes to existing platform implementations (Linux, Windows, QNX)
  • No API changes
  • FreeBSD will use the same POSIX code path as QNX

Ideally, this should be tested on a FreeBSD system to verify:

  • Compilation succeeds
  • Unit tests pass
  • Demo programs work correctly

Files Modified

  • README.md - Added FreeBSD to platform list
  • src/libipc/platform/detail.h - Added FreeBSD platform detection
  • src/libipc/platform/platform.c - Updated conditional compilation
  • src/libipc/platform/platform.cpp - Updated conditional compilation
  • src/libipc/sync/condition.cpp - Updated conditional compilation
  • src/libipc/sync/mutex.cpp - Updated conditional compilation
  • src/libipc/sync/semaphore.cpp - Updated conditional compilation
  • src/libipc/sync/waiter.cpp - Updated conditional compilation

References

Related

Closes #156

- 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.
@mutouyun mutouyun mentioned this pull request Nov 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for FreeBSD

2 participants