Revert "Convert strtold to Rust"

This reverts commit 08485648f6.
This commit is contained in:
Jeremy Soller
2026-01-15 18:31:47 -07:00
parent c8b4a03b45
commit 40c9c14ea8
6 changed files with 42 additions and 10 deletions
+36
View File
@@ -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");
}
+5
View File
@@ -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);
}
-3
View File
@@ -5,8 +5,5 @@ style = "Type"
no_includes = true
cpp_compat = true
[export.rename]
"c_longdouble" = "long double"
[enum]
prefix_with_name = true
+1 -5
View File
@@ -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)]
-1
View File
@@ -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)]
-1
View File
@@ -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;