JH-Toolkit v1.4.1
An engineering-oriented C++20 toolkit with duck-typed concepts, static design, async coroutines, and semantic containers — header-only, RTTI-free, and concurrency-friendly.
Loading...
Searching...
No Matches
ipc_limits.h File Reference

Compile-time validation utilities for IPC object naming and POSIX-style path safety. More...

#include "jh/metax/t_str.h"
#include "jh/macros/platform.h"
#include <cstdint>

Go to the source code of this file.

Namespaces

namespace  jh::sync
 Aggregated entry point for synchronization and coordination facilities.
namespace  jh::sync::ipc
 Synchronous inter-process coordination primitives.
namespace  jh::sync::ipc::limits
 Compile-time constraint and validation utilities for jh::sync::ipc.

Macros

#define JH_INTERPROCESS_ALLOW_PARENT_PATH   0
 Controls whether leading "../" segments are allowed in compile-time validated POSIX-style relative IPC paths.
#define JH_FORCE_SHORT_SEM_NAME   0
 Forces IPC object names to use the strict BSD length limit (30 characters) regardless of detected platform.

Functions

template<jh::meta::TStr S, std::uint64_t MaxLen = max_name_length>
consteval bool jh::sync::ipc::limits::valid_object_name ()
 Validate compile-time IPC object name (for semaphores, shared memory, etc.).
template<jh::meta::TStr S>
consteval bool jh::sync::ipc::limits::valid_relative_path () noexcept
 Compile-time validation for POSIX-style relative paths.

Variables

constexpr std::uint64_t jh::sync::ipc::limits::max_name_length = 128

Detailed Description

Compile-time validation utilities for IPC object naming and POSIX-style path safety.

Overview

This header defines consteval (compile-time evaluated) utilities to enforce platform-aware constraints for inter-process communication (IPC) primitives implemented under jh::sync::ipc.

It validates:

  • IPC object names (used by semaphores, shared memory, conditions, etc.)
  • POSIX-style relative paths (for safe file-based or namespace-based IPC)

All validation occurs entirely at compile time — no runtime overhead is introduced.

Platform-specific limits

  • FreeBSD / Darwin (macOS): maximum = 30 (strict BSD POSIX limit, 31 bytes including leading '/').
  • Linux / Windows / WASM: extended limit = 128 (safe portable maximum across modern systems).
  • If JH_FORCE_SHORT_SEM_NAME is defined as 1, the name length is treated as "same as BSD" (30) regardless of platform. This is used if a non-detected BSD-like environment is targeted or developing cross-platform code on non-BSD systems.

The limit is automatically selected at compile time using jh/macros/platform.h.

Design philosophy

These checks are performed via consteval functions, ensuring:

  • Invalid IPC names or paths cause compile-time errors.
  • No runtime validation or branching is ever emitted.
  • Validation logic is portable and deterministic across compilers.

This design provides early failure detection for illegal resource names and guarantees identical IPC namespace semantics across all supported platforms.