float: Add crate for float.h
Add a crate with stubbed functions for the float.h header.
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
[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" }
|
||||
@@ -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/float.h");
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
sys_includes = ["sys/types.h", "bits/float.h"]
|
||||
include_guard = "_FLOAT_H"
|
||||
language = "C"
|
||||
|
||||
[enum]
|
||||
prefix_with_name = true
|
||||
@@ -0,0 +1,19 @@
|
||||
//! 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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user