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, |
Patrick Williams | d8e0af5 | 2024-08-16 15:21:12 -0400 | [diff] [blame^] | 10 | off_t offset) : mapping(fd.mmap(window, prot, flags, offset), fd) |
Patrick Williams | d1984dd | 2023-05-10 16:12:44 -0500 | [diff] [blame] | 11 | {} |
William A. Kennington III | 891e6a3 | 2022-05-17 16:35:03 -0700 | [diff] [blame] | 12 | |
| 13 | std::span<std::byte> MMap::get() const |
| 14 | { |
| 15 | return *mapping; |
| 16 | } |
| 17 | |
| 18 | void 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 |