diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-03-19 02:01:59 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-19 02:01:59 +0100 |
| commit | a87590e34e18646aee82771471649761d9acf02f (patch) | |
| tree | af34289808188ce7912bc09ce18c85afcd0e7c70 /library/std/src/sys | |
| parent | ba2d5ede70ed7e37d7f13a397b9d554e2386a19c (diff) | |
| parent | bc199b57784ec60bc9492c1a046c585af7ee8ea4 (diff) | |
| download | rust-a87590e34e18646aee82771471649761d9acf02f.tar.gz rust-a87590e34e18646aee82771471649761d9acf02f.zip | |
Rollup merge of #92612 - atopia:update-lib-l4re, r=dtolnay
Update stdlib for the l4re target This PR contains the work by ``@humenda`` and myself to update standard library support for the x86_64-unknown-l4re-uclibc tier 3 target, split out from humenda/rust as requested in #85967. The changes have been rebased on current master and updated in follow up commits by myself. The publishing of the changes is authorized and preferred by the original author. To preserve attribution, when standard library changes were introduced as part of other changes to the compiler, I have kept the changes concerning the standard library and altered the commit messages as indicated. Any incompatibilities have been remedied in follow up commits, so that the PR as a whole should result in a clean update of the target.
Diffstat (limited to 'library/std/src/sys')
| -rw-r--r-- | library/std/src/sys/unix/l4re.rs | 58 | ||||
| -rw-r--r-- | library/std/src/sys/unix/mod.rs | 1 | ||||
| -rw-r--r-- | library/std/src/sys/unix/process/process_unix.rs | 5 |
3 files changed, 49 insertions, 15 deletions
diff --git a/library/std/src/sys/unix/l4re.rs b/library/std/src/sys/unix/l4re.rs index d13e1ecbbfe..f052d8f7f05 100644 --- a/library/std/src/sys/unix/l4re.rs +++ b/library/std/src/sys/unix/l4re.rs @@ -13,6 +13,7 @@ pub mod net { use crate::fmt; use crate::io::{self, IoSlice, IoSliceMut}; use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr}; + use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; use crate::sys::fd::FileDesc; use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::time::Duration; @@ -59,7 +60,7 @@ pub mod net { } pub fn is_read_vectored(&self) -> bool { - unimpl!(); + false } pub fn peek(&self, _: &mut [u8]) -> io::Result<usize> { @@ -83,7 +84,7 @@ pub mod net { } pub fn is_write_vectored(&self) -> bool { - unimpl!(); + false } pub fn set_timeout(&self, _: Option<Duration>, _: libc::c_int) -> io::Result<()> { @@ -121,23 +122,52 @@ pub mod net { pub fn take_error(&self) -> io::Result<Option<io::Error>> { unimpl!(); } + + // This is used by sys_common code to abstract over Windows and Unix. + pub fn as_raw(&self) -> RawFd { + self.as_raw_fd() + } + } + + impl AsInner<FileDesc> for Socket { + fn as_inner(&self) -> &FileDesc { + &self.0 + } + } + + impl FromInner<FileDesc> for Socket { + fn from_inner(file_desc: FileDesc) -> Socket { + Socket(file_desc) + } } - impl AsInner<libc::c_int> for Socket { - fn as_inner(&self) -> &libc::c_int { - self.0.as_inner() + impl IntoInner<FileDesc> for Socket { + fn into_inner(self) -> FileDesc { + self.0 } } - impl FromInner<libc::c_int> for Socket { - fn from_inner(fd: libc::c_int) -> Socket { - Socket(FileDesc::new(fd)) + impl AsFd for Socket { + fn as_fd(&self) -> BorrowedFd<'_> { + self.0.as_fd() } } - impl IntoInner<libc::c_int> for Socket { - fn into_inner(self) -> libc::c_int { - self.0.into_raw() + impl AsRawFd for Socket { + fn as_raw_fd(&self) -> RawFd { + self.0.as_raw_fd() + } + } + + impl IntoRawFd for Socket { + fn into_raw_fd(self) -> RawFd { + self.0.into_raw_fd() + } + } + + impl FromRawFd for Socket { + unsafe fn from_raw_fd(raw_fd: RawFd) -> Self { + Self(FromRawFd::from_raw_fd(raw_fd)) } } @@ -191,7 +221,7 @@ pub mod net { } pub fn is_read_vectored(&self) -> bool { - unimpl!(); + false } pub fn write(&self, _: &[u8]) -> io::Result<usize> { @@ -203,7 +233,7 @@ pub mod net { } pub fn is_write_vectored(&self) -> bool { - unimpl!(); + false } pub fn peer_addr(&self) -> io::Result<SocketAddr> { @@ -497,7 +527,7 @@ pub mod net { impl LookupHost { pub fn port(&self) -> u16 { - unimpl!(); + 0 // unimplemented } } diff --git a/library/std/src/sys/unix/mod.rs b/library/std/src/sys/unix/mod.rs index 605cc499b3c..7423d90263d 100644 --- a/library/std/src/sys/unix/mod.rs +++ b/library/std/src/sys/unix/mod.rs @@ -80,6 +80,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8) { target_os = "macos", target_os = "ios", target_os = "redox", + target_os = "l4re", )))] { use crate::sys::os::errno; let pfds: &mut [_] = &mut [ diff --git a/library/std/src/sys/unix/process/process_unix.rs b/library/std/src/sys/unix/process/process_unix.rs index 9d2803b40c4..2a97a802a20 100644 --- a/library/std/src/sys/unix/process/process_unix.rs +++ b/library/std/src/sys/unix/process/process_unix.rs @@ -27,7 +27,10 @@ use crate::sys::weak::weak; use libc::RTP_ID as pid_t; #[cfg(not(target_os = "vxworks"))] -use libc::{c_int, gid_t, pid_t, uid_t}; +use libc::{c_int, pid_t}; + +#[cfg(not(any(target_os = "vxworks", target_os = "l4re")))] +use libc::{gid_t, uid_t}; //////////////////////////////////////////////////////////////////////////////// // Command |
