Skip to content

Commit 6eaec56

Browse files
committed
library: Remove definitions and reexports of strlen from libstd
1 parent afa2e6f commit 6eaec56

File tree

6 files changed

+0
-40
lines changed

6 files changed

+0
-40
lines changed

library/std/src/sys/hermit/mod.rs

-10
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,6 @@ pub fn unsupported_err() -> crate::io::Error {
7171
)
7272
}
7373

74-
pub unsafe fn strlen(start: *const c_char) -> usize {
75-
let mut str = start;
76-
77-
while *str != 0 {
78-
str = str.offset(1);
79-
}
80-
81-
(str as usize) - (start as usize)
82-
}
83-
8474
#[no_mangle]
8575
pub extern "C" fn floor(x: f64) -> f64 {
8676
unsafe { intrinsics::floorf64(x) }

library/std/src/sys/sgx/mod.rs

-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#![deny(unsafe_op_in_unsafe_fn)]
66

77
use crate::io::ErrorKind;
8-
use crate::os::raw::c_char;
98
use crate::sync::atomic::{AtomicBool, Ordering};
109

1110
pub mod abi;
@@ -130,15 +129,6 @@ pub fn decode_error_kind(code: i32) -> ErrorKind {
130129
}
131130
}
132131

133-
pub unsafe fn strlen(mut s: *const c_char) -> usize {
134-
let mut n = 0;
135-
while unsafe { *s } != 0 {
136-
n += 1;
137-
s = unsafe { s.offset(1) };
138-
}
139-
return n;
140-
}
141-
142132
pub fn abort_internal() -> ! {
143133
abi::usercalls::exit(true)
144134
}

library/std/src/sys/solid/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,3 @@ pub fn hashmap_random_keys() -> (u64, u64) {
9999
(x1, x2)
100100
}
101101
}
102-
103-
pub use libc::strlen;

library/std/src/sys/unix/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use crate::io::ErrorKind;
44

55
pub use self::rand::hashmap_random_keys;
6-
pub use libc::strlen;
76

87
#[cfg(not(target_os = "espidf"))]
98
#[macro_use]

library/std/src/sys/unsupported/common.rs

-16
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ pub mod memchr {
44
pub use core::slice::memchr::{memchr, memrchr};
55
}
66

7-
// This is not necessarily correct. May want to consider making it part of the
8-
// spec definition?
9-
use crate::os::raw::c_char;
10-
117
// SAFETY: must be called only once during runtime initialization.
128
// NOTE: this is not guaranteed to run, for example when Rust code is called externally.
139
pub unsafe fn init(_argc: isize, _argv: *const *const u8) {}
@@ -38,15 +34,3 @@ pub fn abort_internal() -> ! {
3834
pub fn hashmap_random_keys() -> (u64, u64) {
3935
(1, 2)
4036
}
41-
42-
pub unsafe fn strlen(mut s: *const c_char) -> usize {
43-
// SAFETY: The caller must guarantee `s` points to a valid 0-terminated string.
44-
unsafe {
45-
let mut n = 0;
46-
while *s != 0 {
47-
n += 1;
48-
s = s.offset(1);
49-
}
50-
n
51-
}
52-
}

library/std/src/sys/windows/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use crate::path::PathBuf;
77
use crate::time::Duration;
88

99
pub use self::rand::hashmap_random_keys;
10-
pub use libc::strlen;
1110

1211
#[macro_use]
1312
pub mod compat;

0 commit comments

Comments
 (0)