blob: 1f5c211ef05a40f997ab14cce9895a57aca05feb [file] [log] [blame]
William A. Kennington III891e6a32022-05-17 16:35:03 -07001#include <stdplus/fd/mmap.hpp>
2#include <stdplus/util/cexec.hpp>
3
4namespace stdplus
5{
6namespace fd
7{
8
9MMap::MMap(Fd& fd, std::span<std::byte> window, ProtFlags prot, MMapFlags flags,
10 off_t offset) :
11 mapping(fd.mmap(window, prot, flags, offset), fd)
Patrick Williamsd1984dd2023-05-10 16:12:44 -050012{}
William A. Kennington III891e6a32022-05-17 16:35:03 -070013
14std::span<std::byte> MMap::get() const
15{
16 return *mapping;
17}
18
19void MMap::drop(std::span<std::byte>&& mapping, std::reference_wrapper<Fd>& fd)
20{
21 fd.get().munmap(mapping);
22}
23
24} // namespace fd
25} // namespace stdplus