blob: 7026aa62d43e105a40b426f1092c7060541af5d8 [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,
Patrick Williamsd8e0af52024-08-16 15:21:12 -040010 off_t offset) : mapping(fd.mmap(window, prot, flags, offset), fd)
Patrick Williamsd1984dd2023-05-10 16:12:44 -050011{}
William A. Kennington III891e6a32022-05-17 16:35:03 -070012
13std::span<std::byte> MMap::get() const
14{
15 return *mapping;
16}
17
18void MMap::drop(std::span<std::byte>&& mapping, std::reference_wrapper<Fd>& fd)
19{
20 fd.get().munmap(mapping);
21}
22
23} // namespace fd
24} // namespace stdplus