diff --git a/Cargo.toml b/Cargo.toml index af003fd3368073b1cfb40c99dee92f8b439fe8e3..9f0b62d88af19eac380b3aadbdf0eda404547dfb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,7 @@ platform = { path = "platform" } ctype = { path = "src/ctype" } fcntl = { path = "src/fcntl" } grp = { path = "src/grp" } +mman = { path = "src/mman" } stdio = { path = "src/stdio" } stdlib = { path = "src/stdlib" } string = { path = "src/string" } diff --git a/src/mman/Cargo.toml b/src/mman/Cargo.toml new file mode 100644 index 0000000000000000000000000000000000000000..e7e1f0d91588be3e29bc7dbc98b9f67396bbe76c --- /dev/null +++ b/src/mman/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "mman" +version = "0.1.0" +authors = ["Jeremy Soller <jackpot51@gmail.com>"] +build = "build.rs" + +[build-dependencies] +cbindgen = { path = "../../cbindgen" } + +[dependencies] +platform = { path = "../../platform" } diff --git a/src/mman/build.rs b/src/mman/build.rs new file mode 100644 index 0000000000000000000000000000000000000000..0758d24db31b59a65fceebd8e6cf3a1e6aea4a69 --- /dev/null +++ b/src/mman/build.rs @@ -0,0 +1,11 @@ +extern crate cbindgen; + +use std::{env, fs}; + +fn main() { + let crate_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set"); + fs::create_dir_all("../../target/include").expect("failed to create include directory"); + cbindgen::generate(crate_dir) + .expect("failed to generate bindings") + .write_to_file("../../target/include/mman.h"); +} diff --git a/src/mman/cbindgen.toml b/src/mman/cbindgen.toml new file mode 100644 index 0000000000000000000000000000000000000000..84677294aa2cab886f5ff8b4e454eaabaa78b056 --- /dev/null +++ b/src/mman/cbindgen.toml @@ -0,0 +1,6 @@ +sys_includes = [] +include_guard = "_MMAN_H" +language = "C" + +[enum] +prefix_with_name = true diff --git a/src/mman/src/lib.rs b/src/mman/src/lib.rs new file mode 100644 index 0000000000000000000000000000000000000000..e20b1269ff85fa008631bc9841f4cad6004519a9 --- /dev/null +++ b/src/mman/src/lib.rs @@ -0,0 +1,66 @@ +#![no_std] + +extern crate platform; + +use platform::types::*; + +#[no_mangle] +pub extern "C" fn mlock(addr: *const c_void, len: usize) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn mlockall(flags: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn mmap( + addr: *mut c_void, + len: usize, + prot: c_int, + flags: c_int, + fildes: c_int, + off: off_t, +) -> *mut c_void { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn mprotect(addr: *mut c_void, len: usize, prot: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn msync(addr: *mut c_void, len: usize, flags: c_int) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn munlock(addr: *const c_void, len: usize) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn munlockall() -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn munmap(addr: *mut c_void, len: usize) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn shm_open( + name: *const c_char, + oflag: c_int, + mode: mode_t, +) -> c_int { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn shm_unlink(name: *const c_char) -> c_int { + unimplemented!(); +} diff --git a/src/todo/mman/lib.rs b/src/todo/mman/lib.rs deleted file mode 100644 index 4d6f76a369a5080d2fcacb5078cc6c0b50e49e24..0000000000000000000000000000000000000000 --- a/src/todo/mman/lib.rs +++ /dev/null @@ -1,60 +0,0 @@ -#[no_mangle] -pub extern "C" fn mlock(addr: *const libc::c_void, len: usize) -> libc::c_int { - unimplemented!(); -} - -#[no_mangle] -pub extern "C" fn mlockall(flags: libc::c_int) -> libc::c_int { - unimplemented!(); -} - -#[no_mangle] -pub extern "C" fn mmap( - addr: *mut libc::c_void, - len: usize, - prot: libc::c_int, - flags: libc::c_int, - fildes: libc::c_int, - off: off_t, -) -> *mut libc::c_void { - unimplemented!(); -} - -#[no_mangle] -pub extern "C" fn mprotect(addr: *mut libc::c_void, len: usize, prot: libc::c_int) -> libc::c_int { - unimplemented!(); -} - -#[no_mangle] -pub extern "C" fn msync(addr: *mut libc::c_void, len: usize, flags: libc::c_int) -> libc::c_int { - unimplemented!(); -} - -#[no_mangle] -pub extern "C" fn munlock(addr: *const libc::c_void, len: usize) -> libc::c_int { - unimplemented!(); -} - -#[no_mangle] -pub extern "C" fn munlockall() -> libc::c_int { - unimplemented!(); -} - -#[no_mangle] -pub extern "C" fn munmap(addr: *mut libc::c_void, len: usize) -> libc::c_int { - unimplemented!(); -} - -#[no_mangle] -pub extern "C" fn shm_open( - name: *const libc::c_char, - oflag: libc::c_int, - mode: mode_t, -) -> libc::c_int { - unimplemented!(); -} - -#[no_mangle] -pub extern "C" fn shm_unlink(name: *const libc::c_char) -> libc::c_int { - unimplemented!(); -}