Quellcode durchsuchen

fenv: Add crate for fenv.h

Add a crate for building out stub functions and structures for the fenv
header.
Dan Robertson vor 7 Jahren
Ursprung
Commit
f29e6b00d7
6 geänderte Dateien mit 100 neuen und 0 gelöschten Zeilen
  1. 10 0
      Cargo.lock
  2. 1 0
      Cargo.toml
  3. 10 0
      src/fenv/Cargo.toml
  4. 11 0
      src/fenv/build.rs
  5. 6 0
      src/fenv/cbindgen.toml
  6. 62 0
      src/fenv/src/lib.rs

+ 10 - 0
Cargo.lock

@@ -96,6 +96,15 @@ dependencies = [
  "platform 0.1.0",
 ]
 
+[[package]]
+name = "fenv"
+version = "0.1.0"
+dependencies = [
+ "cbindgen 0.5.0",
+ "platform 0.1.0",
+ "resource 0.1.0",
+]
+
 [[package]]
 name = "fuchsia-zircon"
 version = "0.3.3"
@@ -254,6 +263,7 @@ dependencies = [
  "ctype 0.1.0",
  "errno 0.1.0",
  "fcntl 0.1.0",
+ "fenv 0.1.0",
  "grp 0.1.0",
  "mman 0.1.0",
  "platform 0.1.0",

+ 1 - 0
Cargo.toml

@@ -15,6 +15,7 @@ compiler_builtins = { git = "https://github.com/rust-lang-nursery/compiler-built
 ctype = { path = "src/ctype" }
 errno = { path = "src/errno" }
 fcntl = { path = "src/fcntl" }
+fenv = { path = "src/fenv" }
 grp = { path = "src/grp" }
 semaphore = { path = "src/semaphore" }
 mman = { path = "src/mman" }

+ 10 - 0
src/fenv/Cargo.toml

@@ -0,0 +1,10 @@
+[package]
+name = "fenv"
+version = "0.1.0"
+authors = ["Dan Robertson <danlrobertson89@gmail.com>"]
+
+[build-dependencies]
+cbindgen = { path = "../../cbindgen" }
+
+[dependencies]
+platform = { path = "../platform" }

+ 11 - 0
src/fenv/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/fenv.h");
+}

+ 6 - 0
src/fenv/cbindgen.toml

@@ -0,0 +1,6 @@
+sys_includes = ["sys/types.h"]
+include_guard = "_FENV_H"
+language = "C"
+
+[enum]
+prefix_with_name = true

+ 62 - 0
src/fenv/src/lib.rs

@@ -0,0 +1,62 @@
+//! fenv.h implementation for Redox, following
+//! http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fenv.h.html
+
+#![no_std]
+
+extern crate platform;
+
+use platform::types::*;
+
+pub const FE_ALL_EXCEPT: c_int = 0;
+pub const FE_TONEAREST: c_int = 0;
+
+pub type fexcept_t = u64;
+
+#[repr(C)]
+pub struct fenv_t {
+    pub cw: u64,
+}
+
+pub unsafe extern "C" fn feclearexcept(excepts: c_int) -> c_int {
+    unimplemented!();
+}
+
+pub unsafe extern "C" fn fegenenv(envp: *mut fenv_t) -> c_int {
+    unimplemented!();
+}
+
+pub unsafe extern "C" fn fegetexceptflag(flagp: *mut fexcept_t, excepts: c_int) -> c_int {
+    unimplemented!();
+}
+
+pub unsafe extern "C" fn fegetround() -> c_int {
+    FE_TONEAREST
+}
+
+pub unsafe extern "C" fn feholdexcept(envp: *mut fenv_t) -> c_int {
+    unimplemented!();
+}
+
+pub unsafe extern "C" fn feraiseexcept(except: c_int) -> c_int {
+    unimplemented!();
+}
+
+pub unsafe extern "C" fn fesetenv(envp: *const fenv_t) -> c_int {
+    unimplemented!();
+}
+
+pub unsafe extern "C" fn fesetexceptflag(flagp: *const fexcept_t, excepts: c_int) -> c_int {
+    unimplemented!();
+}
+
+pub unsafe extern "C" fn fesetround(round: c_int) -> c_int {
+    unimplemented!();
+}
+
+pub unsafe extern "C" fn fetestexcept(excepts: c_int) -> c_int {
+    unimplemented!();
+}
+
+pub unsafe extern "C" fn feupdateenv(envp: *const fenv_t) -> c_int {
+    unimplemented!();
+}