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()
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.
Replace I/O manipulators (std::hex, std::dec) with ipc::spec in log
statements. The ipc::fmt system does not support std::iostream
manipulators, which caused compilation failures under MinGW.
Changed files:
- src/libipc/platform/win/mutex.h (lines 78, 96)
- src/libipc/platform/win/semaphore.h (line 71)
The format spec "#x" produces output like "0x102" which matches
the original behavior:
- # flag adds the "0x" prefix automatically
- x outputs lowercase hexadecimal
Fixes: #171
- Remove src/libipc/utility/log.h as it's no longer used
- All code has been migrated to use the new libipc/imp/log.h interface
- The old utility/log.h provided printf-style logging: ipc::log() and ipc::error()
- The new imp/log.h provides modern C++ stream-based logging with LIBIPC_LOG() macro
- Verified that there are no remaining references to utility/log.h in the codebase
This completes the log interface migration by removing the deprecated file.
- src/libipc/platform/win/get_sa.h:
* Move 'struct initiator' definition outside get_sa() function
* Rename to 'sa_initiator' to avoid naming conflicts
* Define at namespace ipc::detail scope (above get_sa function)
* Keep template constructor: template <typename Logger> sa_initiator(Logger const &log)
* get_sa() now simply uses: static sa_initiator handle(log);
This fixes the C++ standard violation:
- C++03/11/14/17/20 all prohibit local classes from having member templates
- Error C2892: 'local class shall not have member templates'
- Moving the struct to namespace scope resolves this issue
The struct is now a proper namespace-level definition with a template
constructor, which is fully compliant with C++ standards.
- src/libipc/platform/win/get_sa.h:
* Change from class template to constructor template
* Keep 'struct initiator' as a regular class (not template)
* Make constructor a function template: template <typename Logger> initiator(Logger const &log)
* Instantiate as: static initiator handle(log);
* This is valid C++ as function templates can be defined inside functions
* Fixes the issue that class templates cannot be defined inside functions
The constructor template approach allows proper logger passing while
maintaining valid C++ syntax for local struct definitions.
- src/libipc/platform/win/get_sa.h:
* Convert initiator struct to template with Logger parameter
* Pass log object from get_sa() to initiator constructor via template
* Use 'static initiator<decltype(log)> handle(log)' to instantiate
* This allows initiator constructor to properly access log object
* Syntax: initiator(Logger const &log) receives the logger
- src/libipc/platform/win/semaphore.h:
* Fix format error on line 79: remove extra characters '"}]'
* Correct closing of log.error() statement
* Before: log.error(...)"}]
* After: log.error(...);
These fixes resolve the static struct initialization issue and
code format error in Windows platform.
- src/libipc/platform/win/get_sa.h:
* Fix malformed log.error() calls on lines 19 and 23
* Remove extra comma and parenthesis: GetLastError(, -> GetLastError()
* Fix closing parenthesis and bracket placement
* Line 19: GetLastError(, "]"))) -> GetLastError()), "]"
* Line 23: GetLastError(, "]"))) -> GetLastError()), "]"
- src/libipc/platform/win/mutex.h:
* Add missing LIBIPC_LOG() to try_lock() function at line 84
* The function uses log.error() at line 95 and needs logger initialization
These fixes resolve Windows compilation errors related to malformed
log calls and missing LIBIPC_LOG() macro.
- src/libipc/ipc.cpp:
* Add LIBIPC_LOG() to chunk_storages::get_info() member function
* This was missing, causing 'log' to be undeclared at line 245
* The get_info() function uses log.error() for chunk storage errors
This completes the fix for all missing LIBIPC_LOG() initializations
in the ipc.cpp file.
- src/libipc/prod_cons.h:
* Add LIBIPC_LOG() to second force_push() template function
* This was missing, causing 'log' to be undeclared at line 379
- src/libipc/ipc.cpp:
* Add LIBIPC_LOG() to static send() function (line 590)
* Capture log by reference in outer lambda: [tm, &log]
* Capture log by reference in inner lambda: [tm, &log, info, que, msg_id]
* This fixes 'log' was not declared error in lambda at line 598
* The log variable is now properly captured from the outer send() scope
These fixes ensure that all functions using log.debug/error/warning
have proper LIBIPC_LOG() initialization and lambda captures.
- src/libipc/platform/posix/condition.h:
* Replace all %d and %s format specifiers with stream-based syntax
* Update log.error() calls to use proper streaming (e.g., "[", eno, "]")
- src/libipc/platform/posix/semaphore_impl.h:
* Remove %d format specifiers from log.error() calls
* Fix malformed parentheses (e.g., .c_str(, ""))
* Remove unnecessary empty string arguments
* Use stream-based logging consistently
- src/libipc/platform/win/mutex.h:
* Fix malformed GetLastError() parentheses
* Remove %lu format specifier, use explicit cast instead
* Update to stream-based logging syntax
- src/libipc/platform/win/semaphore.h:
* Fix malformed GetLastError() parentheses
* Remove %lu format specifier, use explicit cast instead
* Update to stream-based logging syntax
All format specifiers (%d, %s, %zd, %p, %lu) have been removed and replaced
with proper C++ stream-based logging that is type-safe and consistent with
the new imp/log interface.
- Add LIBIPC_LOG() to functions in platform files that use log.error/warning/debug
- Fixed files:
- POSIX platform: mutex.h, semaphore_impl.h, shm_posix.cpp
- Windows platform: get_sa.h, mutex.h, semaphore.h, shm_win.cpp
- Sync layer: condition.cpp, mutex.cpp, semaphore.cpp
All functions using the new log interface now properly initialize the logger with LIBIPC_LOG()
- Add LIBIPC_LOG() to calc_wait_time() function
- Add LIBIPC_LOG() to make_timespec() function
- Both functions use log.error() and need the logger initialization
- Fix multi-parameter log calls with complex formatting in POSIX and Windows platforms
- Replace remaining ipc::error() and ipc::log() calls with log.error() and log.warning()
- Handle special cases:
- POSIX condition.h: pthread_cond_timedwait multi-param formatting
- POSIX get_wait_time.h: calc_wait_time multi-param formatting
- POSIX semaphore_impl.h: sem_timedwait multi-param formatting
- Windows mutex.h: WaitForSingleObject with hex formatting, WAIT_ABANDONED as warning
- Windows semaphore.h: WaitForSingleObject and ReleaseSemaphore calls
- Use std::hex/std::dec for hexadecimal formatting in Windows platform
- All log interface migrations now complete
- Replace include "libipc/utility/log.h" with "libipc/imp/log.h"
- Add LIBIPC_LOG() at the beginning of functions that use logging
- Replace all ipc::error() calls with log.error()
- Replace all ipc::log() calls with log.debug() or log.error() based on context
- Modified functions:
- cc_acc(): error logging for shm acquire failure
- make_handle(): error logging for chunk storage operations
- find_storage(): error logging for invalid storage id
- release_storage(): error logging for invalid storage id
- recycle_storage(): error logging for invalid storage id
- clear_message(): error logging for invalid message size
- send(): error logging for various send failures, debug logging for force_push
- recv(): error logging for various recv failures
- Use type-safe streaming interface instead of printf-style formatting
- Remove manual newline characters from log messages
- Total changes: 19 log call sites updated
- Update force_push() log calls to use log.debug() instead of log.warning()
- Debug level is more appropriate for internal force_push diagnostic messages
Fixed two critical issues from the rebase:
1. Added LIBIPC_OS_FREEBSD macro definition in detect_plat.h to enable
FreeBSD platform detection alongside other OS checks
2. Added missing #include "libipc/imp/detect_plat.h" in detail.h to
properly include platform detection macros
These fixes ensure FreeBSD compilation will work correctly with the
unified platform detection system.
The acquire() function allocates id_info_t using mem::$new<id_info_t>(),
so the release() function must use mem::$delete(ii) to deallocate it,
not mem::free(ii). This ensures proper allocation/deallocation pairing.
Issue: Memory allocated with mem::$new must be freed with mem::$delete
to maintain consistent memory management semantics.
ISSUE:
MSVC compiler reports warning C4138: '*/' found outside of comment
for patterns like 'void */*p*/' where the pointer asterisk is immediately
followed by a comment start.
AFFECTED FILES:
- include/libipc/mem/new.h (line 30)
- src/libipc/platform/win/mutex.h (line 54)
- src/libipc/platform/win/semaphore.h (line 53)
CHANGES:
Changed 'type */*param*/' to 'type * /*param*/' (added space before comment)
Examples:
- void */*p*/ → void * /*p*/
- char const */*name*/ → char const * /*name*/
This resolves the MSVC warning while maintaining code functionality
and keeping the commented-out parameter names for documentation.
Fixes#165
- Update project version in root CMakeLists.txt to 1.4.1
- Update PACKAGE_VERSION in src/CMakeLists.txt to 1.4.1
- Ensures compiled library has correct version number for the upcoming 1.4.1 release