Skip to content

Commit 8473ea8

Browse files
committed
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.
1 parent 1aa6aef commit 8473ea8

File tree

21 files changed

+7
-141
lines changed

21 files changed

+7
-141
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/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ pub mod fs;
2727
pub mod futex;
2828
#[path = "../unsupported/io.rs"]
2929
pub mod io;
30-
pub mod memchr;
3130
pub mod net;
3231
pub mod os;
3332
#[path = "../unix/os_str.rs"]

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ 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;
14+
use core::slice::memchr;
1515

1616
pub fn errno() -> i32 {
1717
0

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/solid/os.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ use crate::sync::{PoisonError, RwLock};
1212
use crate::sys::common::small_c_string::run_with_cstr;
1313
use crate::vec;
1414

15-
use super::{error, itron, memchr};
15+
use super::{error, itron};
16+
use core::slice::memchr;
1617

1718
// `solid` directly maps `errno`s to μITRON error codes.
1819
impl itron::error::ItronError {

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

-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ pub mod locks;
2121
pub mod fs;
2222
#[path = "../unsupported/io.rs"]
2323
pub mod io;
24-
#[path = "../unix/memchr.rs"]
25-
pub mod memchr;
2624
pub mod net;
2725
#[path = "../unsupported/once.rs"]
2826
pub mod once;

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

-4
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ use crate::os::uefi;
5757
use crate::ptr::NonNull;
5858
use crate::sync::atomic::{AtomicPtr, Ordering};
5959

60-
pub mod memchr {
61-
pub use core::slice::memchr::{memchr, memrchr};
62-
}
63-
6460
static EXIT_BOOT_SERVICE_EVENT: AtomicPtr<crate::ffi::c_void> =
6561
AtomicPtr::new(crate::ptr::null_mut());
6662

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
@@ -23,7 +23,6 @@ pub mod kernel_copy;
2323
#[cfg(target_os = "l4re")]
2424
mod l4re;
2525
pub mod locks;
26-
pub mod memchr;
2726
#[cfg(not(target_os = "l4re"))]
2827
pub mod net;
2928
#[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/wasi/os.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ use crate::os::wasi::prelude::*;
1010
use crate::path::{self, PathBuf};
1111
use crate::str;
1212
use crate::sys::common::small_c_string::{run_path_with_cstr, run_with_cstr};
13-
use crate::sys::memchr;
1413
use crate::sys::unsupported;
1514
use crate::vec;
15+
use core::slice::memchr;
1616

1717
// Add a few symbols not in upstream `libc` just yet.
1818
mod libc {

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)