16 lines
463 B
Python
16 lines
463 B
Python
"""Shared ring layout; keep in sync with common_cpp/ipc/src/shm_ring.cpp."""
|
|
|
|
from pathlib import Path
|
|
import struct
|
|
|
|
MAGIC = b"RDRRING2"
|
|
VERSION = 1
|
|
HEADER = struct.Struct("<8sIIIIQQQ16x")
|
|
SLOT_HEADER_SIZE = 16
|
|
|
|
|
|
def ring_path(name: str) -> Path:
|
|
if not name.startswith("/") or len(name) < 2 or "/" in name[1:] or "\x00" in name:
|
|
raise ValueError("ring_name must be '/' followed by a single nonempty filename")
|
|
return Path("/dev/shm") / name[1:]
|