/** * @file SharedMemory.h * @author apio (cloudapio.eu) * @brief Create and map areas of memory shared between processes. * * @copyright Copyright (c) 2023, the Luna authors. * */ #include #include namespace os { namespace SharedMemory { /** * @brief Create a new shared memory region and map it. * * @param path The shared memory path to use. It must be of the same format as shm_open(). * @param size The amount of bytes to use for the shared memory region. * @return Result An error, or a pointer to the shared memory region. */ Result create(StringView path, usize size); /** * @brief Map an existing shared memory region, possibly created by another process. * * @param path The shared memory path to use. It must be of the same format as shm_open(). * @param size The amount of bytes to map from the shared memory region. * @param delete_fs Whether to delete the region from the file system so no other processes can open it. * @return Result An error, or a pointer to the shared memory region. */ Result adopt(StringView path, usize size, bool delete_fs = true); }; }