1
Fork 0

library: Remove definitions and reexports of strlen from libstd

This commit is contained in:
Vadim Petrochenkov 2022-04-14 14:38:39 +03:00
parent afa2e6f2ff
commit 6eaec56ef7
6 changed files with 0 additions and 40 deletions

View file

@ -71,16 +71,6 @@ pub fn unsupported_err() -> crate::io::Error {
) )
} }
pub unsafe fn strlen(start: *const c_char) -> usize {
let mut str = start;
while *str != 0 {
str = str.offset(1);
}
(str as usize) - (start as usize)
}
#[no_mangle] #[no_mangle]
pub extern "C" fn floor(x: f64) -> f64 { pub extern "C" fn floor(x: f64) -> f64 {
unsafe { intrinsics::floorf64(x) } unsafe { intrinsics::floorf64(x) }

View file

@ -5,7 +5,6 @@
#![deny(unsafe_op_in_unsafe_fn)] #![deny(unsafe_op_in_unsafe_fn)]
use crate::io::ErrorKind; use crate::io::ErrorKind;
use crate::os::raw::c_char;
use crate::sync::atomic::{AtomicBool, Ordering}; use crate::sync::atomic::{AtomicBool, Ordering};
pub mod abi; pub mod abi;
@ -130,15 +129,6 @@ pub fn decode_error_kind(code: i32) -> ErrorKind {
} }
} }
pub unsafe fn strlen(mut s: *const c_char) -> usize {
let mut n = 0;
while unsafe { *s } != 0 {
n += 1;
s = unsafe { s.offset(1) };
}
return n;
}
pub fn abort_internal() -> ! { pub fn abort_internal() -> ! {
abi::usercalls::exit(true) abi::usercalls::exit(true)
} }

View file

@ -99,5 +99,3 @@ pub fn hashmap_random_keys() -> (u64, u64) {
(x1, x2) (x1, x2)
} }
} }
pub use libc::strlen;

View file

@ -3,7 +3,6 @@
use crate::io::ErrorKind; use crate::io::ErrorKind;
pub use self::rand::hashmap_random_keys; pub use self::rand::hashmap_random_keys;
pub use libc::strlen;
#[cfg(not(target_os = "espidf"))] #[cfg(not(target_os = "espidf"))]
#[macro_use] #[macro_use]

View file

@ -4,10 +4,6 @@ pub mod memchr {
pub use core::slice::memchr::{memchr, memrchr}; pub use core::slice::memchr::{memchr, memrchr};
} }
// This is not necessarily correct. May want to consider making it part of the
// spec definition?
use crate::os::raw::c_char;
// SAFETY: must be called only once during runtime initialization. // SAFETY: must be called only once during runtime initialization.
// NOTE: this is not guaranteed to run, for example when Rust code is called externally. // NOTE: this is not guaranteed to run, for example when Rust code is called externally.
pub unsafe fn init(_argc: isize, _argv: *const *const u8) {} pub unsafe fn init(_argc: isize, _argv: *const *const u8) {}
@ -38,15 +34,3 @@ pub fn abort_internal() -> ! {
pub fn hashmap_random_keys() -> (u64, u64) { pub fn hashmap_random_keys() -> (u64, u64) {
(1, 2) (1, 2)
} }
pub unsafe fn strlen(mut s: *const c_char) -> usize {
// SAFETY: The caller must guarantee `s` points to a valid 0-terminated string.
unsafe {
let mut n = 0;
while *s != 0 {
n += 1;
s = s.offset(1);
}
n
}
}

View file

@ -7,7 +7,6 @@ use crate::path::PathBuf;
use crate::time::Duration; use crate::time::Duration;
pub use self::rand::hashmap_random_keys; pub use self::rand::hashmap_random_keys;
pub use libc::strlen;
#[macro_use] #[macro_use]
pub mod compat; pub mod compat;