mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-07 01:06:45 +08:00
add: [mmap] add interface declarations
This commit is contained in:
parent
e21da4fe2d
commit
29188f939c
@ -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,
|
||||
|
||||
@ -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
7
test/test_ipc_mmap.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "libipc/mmap.h"
|
||||
|
||||
TEST(mmap, create_close) {
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user