425 Commits

Author SHA1 Message Date
mutouyun
8b1dca8831 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()
2026-01-29 03:21:03 +00:00
mutouyun
9ac5c24254 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.
2026-01-29 03:20:25 +00:00
Craig Carnell
717dc0d9c3 webOS: fix std::aligned_alloc build error 2026-01-23 10:56:46 +00:00
木头云
6562e40453
Merge pull request #172 from cscd98/mingw-fixes-latest
Fix compilation under MINGW
2026-01-23 10:25:42 +08:00
Craig Carnell
0c7568a49c mingw: fix std::aligned_alloc usage 2026-01-21 09:20:19 +00:00
mutouyun
642be3629b fix(win): replace std::hex/std::dec with ipc::spec for MinGW compatibility (issue #171)
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
2026-01-21 06:32:50 +00:00
Craig Carnell
e5eff19821 msvc: avoid use of std::aligned_alloc as not available 2026-01-14 14:32:43 +00:00
Craig Carnell
a8752fd170 mingw: lower case for mingw new Windows.h includes 2025-12-31 17:24:18 +00:00
木头云
d6e8f71780 refactor(log): remove deprecated utility/log.h
- 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.
2025-12-18 03:34:24 +00:00
木头云
ab8e6c7d2c fix(log): move sa_initiator struct outside get_sa() function
- 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.
2025-12-15 12:10:26 +00:00
木头云
72eedeb6c4 fix(log): use constructor template instead of class template for initiator
- 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.
2025-12-15 11:58:13 +00:00
木头云
afd1467e03 fix(log): use template to pass logger to initiator and fix format error
- 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.
2025-12-15 11:54:04 +00:00
木头云
66a66f15ec fix(log): fix Windows platform compilation errors
- 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.
2025-12-15 11:42:57 +00:00
木头云
0f8bd3415c fix(log): add missing LIBIPC_LOG() in get_info member function
- 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.
2025-12-15 11:33:17 +00:00
木头云
73d59ba20e fix(log): add missing LIBIPC_LOG() and fix lambda log capture
- 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.
2025-12-15 10:21:40 +00:00
木头云
2b1ed4bc51 fix(log): remove remaining format specifiers and fix malformed log calls
- 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.
2025-12-15 10:06:52 +00:00
木头云
1664526c40 fix(log): fix malformed log calls and add missing LIBIPC_LOG() in shm files
- src/libipc/platform/posix/shm_posix.cpp:
  * Add LIBIPC_LOG() to acquire() and get_mem() functions
  * Fix malformed log.error() calls: remove format specifiers (%d, %zd, %p)
  * Fix parentheses errors in log.error() calls (e.g., .c_str(, ""))
  * Use stream-based logging instead of printf-style formatting

- src/libipc/platform/win/shm_win.cpp:
  * Add LIBIPC_LOG() to acquire() and get_mem() functions
  * Fix malformed log.error() calls with GetLastError()
  * Fix parentheses errors in log.error() calls
  * Ensure consistent stream-based logging syntax

These fixes address syntax errors that would have caused compilation failures.
2025-12-15 10:02:23 +00:00
木头云
2ff5c94479 fix(log): add missing LIBIPC_LOG() to all functions using 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()
2025-12-15 09:48:54 +00:00
木头云
298354973a fix(log): add missing LIBIPC_LOG() in posix get_wait_time.h
- 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
2025-12-15 09:47:39 +00:00
木头云
0c4421d5c2 refactor(log): fix remaining complex log format calls
- 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
2025-12-15 09:40:37 +00:00
木头云
e9a7dbaa74 refactor(log): replace utility/log with imp/log in all platform and sync files
- Replace include "libipc/utility/log.h" with "libipc/imp/log.h" in all files
- Add LIBIPC_LOG() to functions that use logging
- Replace ipc::error() and ipc::log() calls with log.error() and log.debug()
- Use type-safe streaming interface instead of printf-style formatting
- Remove manual newline characters from log messages

Modified files:
- Linux platform: condition.h, get_wait_time.h, mutex.h, sync_obj_impl.h
- POSIX platform: condition.h, get_wait_time.h, mutex.h, semaphore_impl.h, shm_posix.cpp
- Windows platform: condition.h, get_sa.h, mutex.h, semaphore.h, shm_win.cpp
- Sync layer: condition.cpp, mutex.cpp, semaphore.cpp

Total: 17 files updated with comprehensive log interface migration
2025-12-15 09:37:50 +00:00
木头云
6143c23fd3 refactor(log): replace utility/log with imp/log in ipc.cpp
- 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
2025-12-15 09:02:00 +00:00
木头云
309baf77bc refactor(log): change log level from warning to debug in prod_cons.h
- Update force_push() log calls to use log.debug() instead of log.warning()
- Debug level is more appropriate for internal force_push diagnostic messages
2025-12-15 08:47:42 +00:00
木头云
bf62216e8d refactor(log): replace utility/log with imp/log in prod_cons.h and queue.h
- Replace include "libipc/utility/log.h" with "libipc/imp/log.h"
- prod_cons.h: Replace ipc::log() calls with LIBIPC_LOG() + log.warning()
  - Updated 2 force_push() template functions in broadcast implementations
  - Changed log level from generic log to warning for force_push scenarios
- queue.h: Replace ipc::error() calls with LIBIPC_LOG() + log.error()
  - Updated queue_conn::open() template function
- Use type-safe streaming interface instead of printf-style formatting
- Remove manual newline characters from log messages
2025-12-15 08:43:13 +00:00
木头云
2ec1914691 refactor(log): replace utility/log with imp/log in shm.cpp
- Replace include "libipc/utility/log.h" with "libipc/imp/log.h"
- Replace ipc::error() calls with LIBIPC_LOG() + log.error()
- Use type-safe streaming interface instead of printf-style formatting
- Remove manual newline characters from log messages
2025-12-15 08:33:43 +00:00
mutouyun
e38d3ed801 fix(platform): Add FreeBSD detection and include detect_plat.h in detail.h
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.
2025-12-12 07:04:31 +00:00
木头云
542706117a fix(shm_win): Use mem::$delete instead of mem::free in release()
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.
2025-12-12 07:04:31 +00:00
木头云
cc33f73eec fix(msvc): Fix C4138 warning by adding space before commented parameter names
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.
2025-12-12 07:04:31 +00:00
mutouyun
90b7badcee Replace custom hash struct with std::hash in unordered_map definition 2025-12-12 07:04:31 +00:00
mutouyun
165060e0b6 Fix the issue caused by inconsistent lifecycle of the global IPC object. 2025-12-12 07:04:31 +00:00
mutouyun
63f35484d7 Refactoring the generic memory allocator 2025-12-12 07:04:31 +00:00
mutouyun
716992cade Reimplement the allocator required for the container type with $new 2025-12-12 07:04:31 +00:00
mutouyun
41529e8eb3 Use $new instead of alloc 2025-12-12 07:04:31 +00:00
mutouyun
00ee30e339 libipc/memory/resource.h => libipc/mem/resource.h 2025-12-12 07:04:31 +00:00
mutouyun
9a2e1b237a Add block_pool 2025-12-12 07:04:31 +00:00
mutouyun
0035764e0d Adjust the allocator name 2025-12-12 07:04:31 +00:00
mutouyun
93d6c44771 Simplify verify_args function to fix error C3249 2025-12-12 07:04:31 +00:00
mutouyun
9276fcbcda Fix fmt function to handle null pointers and return empty string 2025-12-12 07:04:31 +00:00
mutouyun
d00dcbbf15 Fix fmt function to handle empty strings and update make_prefix template parameters 2025-12-12 07:04:31 +00:00
mutouyun
c77a29e9fb Optimize memory_resource & add monotonic_buffer_resource 2025-12-12 07:04:31 +00:00
mutouyun
397b362338 Add allocator and rewrite allocator_wrapper 2025-12-12 07:04:31 +00:00
mutouyun
7536757064 Optimized partial implementation using fmt 2025-12-12 07:04:31 +00:00
mutouyun
106837ffce Start refactoring memory management, adding memory_resource 2025-12-12 07:04:31 +00:00
mutouyun
975ecba2e3 Update platform-specific feature macros to new interfaces in imp 2025-12-12 07:04:31 +00:00
mutouyun
52951e44f8 Add system 2025-12-12 07:04:31 +00:00
mutouyun
5f75f1d738 Add result 2025-12-12 07:04:31 +00:00
mutouyun
bc29c85c1a Add fmt 2025-12-12 07:04:31 +00:00
mutouyun
95bf3afe9b Add codecvt 2025-12-12 07:04:31 +00:00
mutouyun
a4eeac7217 Add nameof & scope_exit 2025-12-12 07:04:31 +00:00
木头云
ab4e5bd18e fix: update library version to 1.4.1 in CMakeLists.txt
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
2025-12-12 06:55:05 +00:00