William A. Kennington III | 891e6a3 | 2022-05-17 16:35:03 -0700 | [diff] [blame] | 1 | #include <stdplus/fd/mmap.hpp> |
| 2 | #include <stdplus/util/cexec.hpp> |
| 3 | |
| 4 | namespace stdplus |
| 5 | { |
| 6 | namespace fd |
| 7 | { |
| 8 | |
| 9 | MMap::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) |
| 12 | { |
| 13 | } |
| 14 | |
| 15 | std::span<std::byte> MMap::get() const |
| 16 | { |
| 17 | return *mapping; |
| 18 | } |
| 19 | |
| 20 | void MMap::drop(std::span<std::byte>&& mapping, std::reference_wrapper<Fd>& fd) |
| 21 | { |
| 22 | fd.get().munmap(mapping); |
| 23 | } |
| 24 | |
| 25 | } // namespace fd |
| 26 | } // namespace stdplus |