Skip to content
Snippets Groups Projects
Verified Commit 3699b53b authored by Dan Robertson's avatar Dan Robertson
Browse files

float: Add crate for float.h

Add a crate with stubbed functions for the float.h header.
parent f29e6b00
No related branches found
No related tags found
No related merge requests found
...@@ -102,7 +102,15 @@ version = "0.1.0" ...@@ -102,7 +102,15 @@ version = "0.1.0"
dependencies = [ dependencies = [
"cbindgen 0.5.0", "cbindgen 0.5.0",
"platform 0.1.0", "platform 0.1.0",
"resource 0.1.0", ]
[[package]]
name = "float"
version = "0.1.0"
dependencies = [
"cbindgen 0.5.0",
"fenv 0.1.0",
"platform 0.1.0",
] ]
[[package]] [[package]]
...@@ -264,6 +272,7 @@ dependencies = [ ...@@ -264,6 +272,7 @@ dependencies = [
"errno 0.1.0", "errno 0.1.0",
"fcntl 0.1.0", "fcntl 0.1.0",
"fenv 0.1.0", "fenv 0.1.0",
"float 0.1.0",
"grp 0.1.0", "grp 0.1.0",
"mman 0.1.0", "mman 0.1.0",
"platform 0.1.0", "platform 0.1.0",
......
...@@ -16,6 +16,7 @@ ctype = { path = "src/ctype" } ...@@ -16,6 +16,7 @@ ctype = { path = "src/ctype" }
errno = { path = "src/errno" } errno = { path = "src/errno" }
fcntl = { path = "src/fcntl" } fcntl = { path = "src/fcntl" }
fenv = { path = "src/fenv" } fenv = { path = "src/fenv" }
float = { path = "src/float" }
grp = { path = "src/grp" } grp = { path = "src/grp" }
semaphore = { path = "src/semaphore" } semaphore = { path = "src/semaphore" }
mman = { path = "src/mman" } mman = { path = "src/mman" }
......
#ifndef _BITS_FLOAT_H
#define _BITS_FLOAT_H
#define FLT_ROUNDS (flt_rounds())
#endif
[package]
name = "float"
version = "0.1.0"
authors = ["Dan Robertson <danlrobertson89@gmail.com>"]
[build-dependencies]
cbindgen = { path = "../../cbindgen" }
[dependencies]
platform = { path = "../platform" }
fenv = { path = "../fenv" }
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/float.h");
}
sys_includes = ["sys/types.h", "bits/float.h"]
include_guard = "_FLOAT_H"
language = "C"
[enum]
prefix_with_name = true
//! float.h implementation for Redox, following
//! http://pubs.opengroup.org/onlinepubs/7908799/xsh/float.h.html
#![no_std]
extern crate fenv;
extern crate platform;
use platform::types::*;
use fenv::{fegetround, FE_TONEAREST};
pub const FLT_RADIX: c_int = 2;
pub unsafe extern "C" fn flt_rounds() -> c_int {
match fegetround() {
FE_TONEAREST => 1,
_ => -1,
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment