@@ -0,0 +1,36 @@
|
||||
extern crate cc;
|
||||
|
||||
use std::{env, fs};
|
||||
|
||||
fn get_target() -> String {
|
||||
env::var("TARGET").unwrap_or(
|
||||
option_env!("TARGET").map_or("x86_64-unknown-redox".to_string(), |x| x.to_string()),
|
||||
)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _crate_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");
|
||||
let target = get_target();
|
||||
|
||||
println!("cargo:rerun-if-changed=src/c");
|
||||
|
||||
let mut cc_builder = &mut cc::Build::new();
|
||||
|
||||
cc_builder = cc_builder.flag("-nostdinc").flag("-nostdlib");
|
||||
|
||||
if target.starts_with("aarch64") {
|
||||
cc_builder = cc_builder.flag("-mno-outline-atomics")
|
||||
}
|
||||
|
||||
cc_builder
|
||||
.flag("-fno-stack-protector")
|
||||
.flag("-Wno-expansion-to-defined")
|
||||
.files(
|
||||
fs::read_dir("src/c")
|
||||
.expect("src/c directory missing")
|
||||
.map(|res| res.expect("read_dir error").path()),
|
||||
)
|
||||
.compile("relibc_c");
|
||||
|
||||
println!("cargo:rustc-link-lib=static=relibc_c");
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
double strtod(const char *nptr, char **endptr);
|
||||
|
||||
long double strtold(const char *nptr, char **endptr) {
|
||||
return (long double)strtod(nptr, endptr);
|
||||
}
|
||||
@@ -5,8 +5,5 @@ style = "Type"
|
||||
no_includes = true
|
||||
cpp_compat = true
|
||||
|
||||
[export.rename]
|
||||
"c_longdouble" = "long double"
|
||||
|
||||
[enum]
|
||||
prefix_with_name = true
|
||||
|
||||
@@ -1479,11 +1479,7 @@ pub unsafe extern "C" fn strtol(s: *const c_char, endptr: *mut *mut c_char, base
|
||||
)
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/strtold.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn strtold(s: *const c_char, endptr: *mut *mut c_char) -> c_longdouble {
|
||||
strto_float_impl!(c_longdouble, s, endptr)
|
||||
}
|
||||
// TODO: strtold(), when long double is available
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/strtol.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#![feature(asm_const)]
|
||||
#![feature(c_variadic)]
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(f128)]
|
||||
#![feature(macro_derive)]
|
||||
#![feature(maybe_uninit_slice)]
|
||||
#![feature(lang_items)]
|
||||
|
||||
@@ -31,7 +31,6 @@ pub type c_int = i32;
|
||||
pub type c_uint = u32;
|
||||
pub type c_float = f32;
|
||||
pub type c_double = f64;
|
||||
pub type c_longdouble = f128;
|
||||
pub type c_longlong = i64;
|
||||
pub type c_ulonglong = u64;
|
||||
pub type intmax_t = i64;
|
||||
|
||||
Reference in New Issue
Block a user