Skip to content

Commit

Permalink
library: Remove definitions and reexports of strlen from libstd
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Apr 14, 2022
1 parent afa2e6f commit 6eaec56
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 40 deletions.
10 changes: 0 additions & 10 deletions library/std/src/sys/hermit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down
10 changes: 0 additions & 10 deletions library/std/src/sys/sgx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 0 additions & 2 deletions library/std/src/sys/solid/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,3 @@ pub fn hashmap_random_keys() -> (u64, u64) {
(x1, x2)
}
}

pub use libc::strlen;
1 change: 0 additions & 1 deletion library/std/src/sys/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
16 changes: 0 additions & 16 deletions library/std/src/sys/unsupported/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down Expand Up @@ -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
}
}
1 change: 0 additions & 1 deletion library/std/src/sys/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6eaec56

Please sign in to comment.