Skip to content

Commit 86b7b71

Browse files
committed
Auto merge of rust-lang#114016 - krtab:delete_sys_memchr, r=workingjubilee
Delete architecture-specific memchr code in std::sys Currently all architecture-specific memchr code is only used in `std::io`. Most of the actual `memchr` capacity exposed to the user through the slice API is instead implemented in `core::slice::memchr`. Hence this commit deletes `memchr` from `std::sys[_common]` and replace calls to it by calls to `core::slice::memchr` functions. This deletes `(r)memchr` from the list of symbols linked to libc. The interest of putting architecture specific code back in core is linked to the discussion to be had in rust-lang#113654
2 parents c9d85d6 + 8655cbf commit 86b7b71

File tree

16 files changed

+3
-132
lines changed

16 files changed

+3
-132
lines changed

library/std/src/io/buffered/linewritershim.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::io::{self, BufWriter, IoSlice, Write};
2-
use crate::sys_common::memchr;
2+
use core::slice::memchr;
33

44
/// Private helper struct for implementing the line-buffered writing logic.
55
/// This shim temporarily wraps a BufWriter, and uses its internals to

library/std/src/io/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ use crate::ops::{Deref, DerefMut};
304304
use crate::slice;
305305
use crate::str;
306306
use crate::sys;
307-
use crate::sys_common::memchr;
307+
use core::slice::memchr;
308308

309309
#[stable(feature = "bufwriter_into_parts", since = "1.56.0")]
310310
pub use self::buffered::WriterPanicked;

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

-1
This file was deleted.

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

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use crate::path::{self, PathBuf};
99
use crate::str;
1010
use crate::sync::Mutex;
1111
use crate::sys::hermit::abi;
12-
use crate::sys::memchr;
1312
use crate::sys::unsupported;
1413
use crate::vec;
1514

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

-1
This file was deleted.

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

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ pub mod fd;
2121
pub mod fs;
2222
#[path = "../unsupported/io.rs"]
2323
pub mod io;
24-
pub mod memchr;
2524
pub mod net;
2625
pub mod os;
2726
#[path = "../unix/os_str.rs"]

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

-21
This file was deleted.

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

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ pub mod pipe;
4040
pub mod process;
4141
pub mod stdio;
4242
pub use self::itron::thread;
43-
pub mod memchr;
4443
pub mod thread_local_dtor;
4544
pub mod thread_local_key;
4645
pub use self::itron::thread_parking;

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

-40
This file was deleted.

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

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ pub mod kernel_copy;
2424
#[cfg(target_os = "l4re")]
2525
mod l4re;
2626
pub mod locks;
27-
pub mod memchr;
2827
#[cfg(not(target_os = "l4re"))]
2928
pub mod net;
3029
#[cfg(target_os = "l4re")]

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ use crate::sync::{PoisonError, RwLock};
2121
use crate::sys::common::small_c_string::{run_path_with_cstr, run_with_cstr};
2222
use crate::sys::cvt;
2323
use crate::sys::fd;
24-
use crate::sys::memchr;
2524
use crate::vec;
25+
use core::slice::memchr;
2626

2727
#[cfg(all(target_env = "gnu", not(target_os = "vxworks")))]
2828
use crate::sys::weak::weak;

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

-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
use crate::io as std_io;
22

3-
pub mod memchr {
4-
pub use core::slice::memchr::{memchr, memrchr};
5-
}
6-
73
// SAFETY: must be called only once during runtime initialization.
84
// NOTE: this is not guaranteed to run, for example when Rust code is called externally.
95
pub unsafe fn init(_argc: isize, _argv: *const *const u8, _sigpipe: u8) {}

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

-5
This file was deleted.

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

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ pub mod fs;
2121
pub mod handle;
2222
pub mod io;
2323
pub mod locks;
24-
pub mod memchr;
2524
pub mod net;
2625
pub mod os;
2726
pub mod os_str;

library/std/src/sys_common/memchr.rs

-51
This file was deleted.

library/std/src/sys_common/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ pub mod backtrace;
2424
pub mod fs;
2525
pub mod io;
2626
pub mod lazy_box;
27-
pub mod memchr;
2827
pub mod once;
2928
pub mod process;
3029
pub mod thread;

0 commit comments

Comments
 (0)