diff --git a/library/std/src/sys/hermit/mod.rs b/library/std/src/sys/hermit/mod.rs index 08eca423802..60b7a973cc2 100644 --- a/library/std/src/sys/hermit/mod.rs +++ b/library/std/src/sys/hermit/mod.rs @@ -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] pub extern "C" fn floor(x: f64) -> f64 { unsafe { intrinsics::floorf64(x) } diff --git a/library/std/src/sys/sgx/mod.rs b/library/std/src/sys/sgx/mod.rs index 1333edb9881..696400670e0 100644 --- a/library/std/src/sys/sgx/mod.rs +++ b/library/std/src/sys/sgx/mod.rs @@ -5,7 +5,6 @@ #![deny(unsafe_op_in_unsafe_fn)] use crate::io::ErrorKind; -use crate::os::raw::c_char; use crate::sync::atomic::{AtomicBool, Ordering}; 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() -> ! { abi::usercalls::exit(true) } diff --git a/library/std/src/sys/solid/mod.rs b/library/std/src/sys/solid/mod.rs index 492b1a55475..5ffa381f2e5 100644 --- a/library/std/src/sys/solid/mod.rs +++ b/library/std/src/sys/solid/mod.rs @@ -99,5 +99,3 @@ pub fn hashmap_random_keys() -> (u64, u64) { (x1, x2) } } - -pub use libc::strlen; diff --git a/library/std/src/sys/unix/mod.rs b/library/std/src/sys/unix/mod.rs index 3ad03a88681..aedeb02e656 100644 --- a/library/std/src/sys/unix/mod.rs +++ b/library/std/src/sys/unix/mod.rs @@ -3,7 +3,6 @@ use crate::io::ErrorKind; pub use self::rand::hashmap_random_keys; -pub use libc::strlen; #[cfg(not(target_os = "espidf"))] #[macro_use] diff --git a/library/std/src/sys/unsupported/common.rs b/library/std/src/sys/unsupported/common.rs index 5274f53a7db..4c9ade4a8c7 100644 --- a/library/std/src/sys/unsupported/common.rs +++ b/library/std/src/sys/unsupported/common.rs @@ -4,10 +4,6 @@ pub mod memchr { 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. // 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) {} @@ -38,15 +34,3 @@ pub fn abort_internal() -> ! { pub fn hashmap_random_keys() -> (u64, u64) { (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 - } -} diff --git a/library/std/src/sys/windows/mod.rs b/library/std/src/sys/windows/mod.rs index 47917e57b19..31c7208bbf1 100644 --- a/library/std/src/sys/windows/mod.rs +++ b/library/std/src/sys/windows/mod.rs @@ -7,7 +7,6 @@ use crate::path::PathBuf; use crate::time::Duration; pub use self::rand::hashmap_random_keys; -pub use libc::strlen; #[macro_use] pub mod compat;