Skip to content

Add extra functions & constants from sys/mman.h for Redox #1762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/unix/redox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,23 @@ pub const TIOCSPGRP: ::c_ulong = 0x5410;
pub const TIOCGWINSZ: ::c_ulong = 0x5413;
pub const TIOCSWINSZ: ::c_ulong = 0x5414;

// sys/mman.h
pub const PROT_NONE: ::c_int = 0x0000;
pub const PROT_READ: ::c_int = 0x0004;
pub const PROT_WRITE: ::c_int = 0x0002;
pub const PROT_EXEC: ::c_int = 0x0001;

pub const MAP_SHARED: ::c_int = 0x0001;
pub const MAP_PRIVATE: ::c_int = 0x0002;
pub const MAP_ANON: ::c_int = 0x0020;
pub const MAP_ANONYMOUS: ::c_int = MAP_ANON;
pub const MAP_FIXED: ::c_int = 0x0010;
pub const MAP_FAILED: *mut ::c_void = !0 as _;

pub const MS_ASYNC: ::c_int = 0x0001;
pub const MS_INVALIDATE: ::c_int = 0x0002;
pub const MS_SYNC: ::c_int = 0x0004;

// sys/select.h
pub const FD_SETSIZE: usize = 1024;

Expand Down Expand Up @@ -934,6 +951,24 @@ extern "C" {
// sys/ioctl.h
pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;

// sys/mman.h
pub fn msync(
addr: *mut ::c_void,
len: ::size_t,
flags: ::c_int,
) -> ::c_int;
pub fn mprotect(
addr: *mut ::c_void,
len: ::size_t,
prot: ::c_int,
) -> ::c_int;
pub fn shm_open(
name: *const c_char,
oflag: ::c_int,
mode: mode_t,
) -> ::c_int;
pub fn shm_unlink(name: *const ::c_char) -> ::c_int;

// sys/resource.h
pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int;
pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int;
Expand Down