diff options
| author | bors <bors@rust-lang.org> | 2023-04-12 04:50:01 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-04-12 04:50:01 +0000 |
| commit | 0d7ed3ba8445452013dd873dc9abcad41a3d82b2 (patch) | |
| tree | e4cae5e26f0f39289e47916af466cc1c74c96c91 /library/std/src/sys | |
| parent | 13d1802b8882452f7d9d1bf514a096c5c8a22303 (diff) | |
| parent | 4c9cd9e739c0b746db1c5912290cb8a9a83089a2 (diff) | |
| download | rust-0d7ed3ba8445452013dd873dc9abcad41a3d82b2.tar.gz rust-0d7ed3ba8445452013dd873dc9abcad41a3d82b2.zip | |
Auto merge of #110214 - compiler-errors:rollup-mkig4t6, r=compiler-errors
Rollup of 10 pull requests Successful merges: - #96971 (Initial support for loongarch64-unknown-linux-gnu) - #109894 (Remove Errors section from var_os docs) - #110000 (Rename tests/ui/unique to tests/ui/box/unit) - #110018 (Pass host linker to compiletest.) - #110104 ( Reword the docstring in todo! macro definition, fixing a typo) - #110113 (Fix `x test ui --target foo` when download-rustc is enabled) - #110126 (Support safe transmute in new solver) - #110155 (Fix typos in librustdoc, tools and config files) - #110162 (rustdoc: remove redundant expandSection code from main.js) - #110173 (kmc-solid: Implement `Socket::read_buf`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library/std/src/sys')
| -rw-r--r-- | library/std/src/sys/common/alloc.rs | 1 | ||||
| -rw-r--r-- | library/std/src/sys/solid/net.rs | 23 |
2 files changed, 18 insertions, 6 deletions
diff --git a/library/std/src/sys/common/alloc.rs b/library/std/src/sys/common/alloc.rs index 403a5e627f1..a5fcbdf39c6 100644 --- a/library/std/src/sys/common/alloc.rs +++ b/library/std/src/sys/common/alloc.rs @@ -22,6 +22,7 @@ pub const MIN_ALIGN: usize = 8; #[cfg(any( target_arch = "x86_64", target_arch = "aarch64", + target_arch = "loongarch64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64", diff --git a/library/std/src/sys/solid/net.rs b/library/std/src/sys/solid/net.rs index 1b98ef993b0..7d7bfae1432 100644 --- a/library/std/src/sys/solid/net.rs +++ b/library/std/src/sys/solid/net.rs @@ -2,7 +2,7 @@ use super::abi; use crate::{ cmp, ffi::CStr, - io::{self, ErrorKind, IoSlice, IoSliceMut}, + io::{self, BorrowedBuf, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut}, mem, net::{Shutdown, SocketAddr}, ptr, str, @@ -294,19 +294,30 @@ impl Socket { self.0.duplicate().map(Socket) } - fn recv_with_flags(&self, buf: &mut [u8], flags: c_int) -> io::Result<usize> { + fn recv_with_flags(&self, mut buf: BorrowedCursor<'_>, flags: c_int) -> io::Result<()> { let ret = cvt(unsafe { - netc::recv(self.0.raw(), buf.as_mut_ptr() as *mut c_void, buf.len(), flags) + netc::recv(self.0.raw(), buf.as_mut().as_mut_ptr().cast(), buf.capacity(), flags) })?; - Ok(ret as usize) + unsafe { + buf.advance(ret as usize); + } + Ok(()) } pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> { - self.recv_with_flags(buf, 0) + let mut buf = BorrowedBuf::from(buf); + self.recv_with_flags(buf.unfilled(), 0)?; + Ok(buf.len()) } pub fn peek(&self, buf: &mut [u8]) -> io::Result<usize> { - self.recv_with_flags(buf, MSG_PEEK) + let mut buf = BorrowedBuf::from(buf); + self.recv_with_flags(buf.unfilled(), MSG_PEEK)?; + Ok(buf.len()) + } + + pub fn read_buf(&self, buf: BorrowedCursor<'_>) -> io::Result<()> { + self.recv_with_flags(buf, 0) } pub fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> { |
