Parcourir la source

Merge pull request #9 from sajattack/mman

build mman header
Jeremy Soller il y a 7 ans
Parent
commit
50af0031c3
6 fichiers modifiés avec 95 ajouts et 60 suppressions
  1. 1 0
      Cargo.toml
  2. 11 0
      src/mman/Cargo.toml
  3. 11 0
      src/mman/build.rs
  4. 6 0
      src/mman/cbindgen.toml
  5. 66 0
      src/mman/src/lib.rs
  6. 0 60
      src/todo/mman/lib.rs

+ 1 - 0
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" }

+ 11 - 0
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" }

+ 11 - 0
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");
+}

+ 6 - 0
src/mman/cbindgen.toml

@@ -0,0 +1,6 @@
+sys_includes = []
+include_guard = "_MMAN_H"
+language = "C"
+
+[enum]
+prefix_with_name = true

+ 66 - 0
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!();
+}

+ 0 - 60
src/todo/mman/lib.rs

@@ -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!();
-}