Skip to content

Commit

Permalink
add mman::mprotect
Browse files Browse the repository at this point in the history
  • Loading branch information
acfoltzer committed Dec 5, 2018
1 parent f278094 commit 0778851
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Added
- Added an `mprotect` wrapper.
([#991](https://github.com/nix-rust/nix/pull/991))
### Changed
### Fixed
### Removed
Expand Down
4 changes: 4 additions & 0 deletions src/sys/mman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ pub unsafe fn madvise(addr: *mut c_void, length: size_t, advise: MmapAdvise) ->
Errno::result(libc::madvise(addr, length, advise as i32)).map(drop)
}

pub unsafe fn mprotect(addr: *mut c_void, length: size_t, prot: ProtFlags) -> Result<()> {
Errno::result(libc::mprotect(addr, length, prot.bits())).map(drop)
}

pub unsafe fn msync(addr: *mut c_void, length: size_t, flags: MsFlags) -> Result<()> {
Errno::result(libc::msync(addr, length, flags.bits())).map(drop)
}
Expand Down

0 comments on commit 0778851

Please sign in to comment.