add: [mmap] add interface declarations

This commit is contained in:
mutouyun 2022-05-15 19:35:58 +08:00
parent e21da4fe2d
commit 29188f939c
6 changed files with 29 additions and 2 deletions

View File

@ -19,7 +19,8 @@ LIBIPC_NAMESPACE_BEG_
// constants
struct prot {
enum : std::uint32_t {
using type = std::uint32_t;
enum : type {
none = 0x00,
read = 0x01,
write = 0x02,

View File

@ -6,6 +6,9 @@
*/
#pragma once
#include <string>
#include <cstddef>
#include "libimp/export.h"
#include "libimp/result.h"
@ -19,6 +22,22 @@ using mmap_t = mmap_handle *;
/**
* @brief Creates a new mapping in the virtual address space of the calling process.
*/
LIBIMP_EXPORT ::LIBIMP_::result<mmap_t> mmap_open();
LIBIMP_EXPORT ::LIBIMP_::result<mmap_t> mmap_open(std::string const &file,
std::size_t size = 0,
prot::type = prot::read | prot::write) noexcept;
/**
* @brief Close the memory mapping handle.
*/
LIBIMP_EXPORT ::LIBIMP_::result_code mmap_close(mmap_t) noexcept;
/**
* @brief Synchronize a file with a memory map.
*/
LIBIMP_EXPORT ::LIBIMP_::result_code mmap_sync(mmap_t) noexcept;
LIBIMP_EXPORT void * mmap_get (mmap_t) noexcept;
LIBIMP_EXPORT std::size_t mmap_size(mmap_t) noexcept;
LIBIMP_EXPORT std::string mmap_file(mmap_t) noexcept;
LIBIPC_NAMESPACE_END_

7
test/test_ipc_mmap.cpp Normal file
View File

@ -0,0 +1,7 @@
#include "gtest/gtest.h"
#include "libipc/mmap.h"
TEST(mmap, create_close) {
}