1 From d1d5c0e5272a8c3f78e9c4eb97c38d8f5d5a6d87 Mon Sep 17 00:00:00 2001
2 From: bjorn3 <bjorn3@users.noreply.github.com>
3 Date: Sat, 17 Nov 2018 11:13:19 +0100
4 Subject: [PATCH] Replace some variadic function calls with unimplemented!()
7 src/libstd/sys/unix/fd.rs | 18 ++++++++++++++++++
8 src/libstd/sys/unix/fs.rs | 17 ++++++++++++++++-
9 src/libstd/sys/unix/net.rs | 3 +++
10 src/libstd/sys/unix/rand.rs | 3 +++
11 src/libstd/sys/unix/thread.rs | 3 +++
12 5 files changed, 43 insertions(+), 1 deletion(-)
14 diff --git a/src/libstd/sys/unix/fd.rs b/src/libstd/sys/unix/fd.rs
15 index 5a81d6d..919f9d1 100644
16 --- a/src/libstd/sys/unix/fd.rs
17 +++ b/src/libstd/sys/unix/fd.rs
18 @@ -156,9 +156,12 @@ impl FileDesc {
20 #[cfg(target_os = "linux")]
21 pub fn get_cloexec(&self) -> io::Result<bool> {
24 Ok((cvt(libc::fcntl(self.fd, libc::F_GETFD))? & libc::FD_CLOEXEC) != 0)
30 #[cfg(not(any(target_env = "newlib",
31 @@ -168,10 +171,13 @@ impl FileDesc {
33 target_os = "haiku")))]
34 pub fn set_cloexec(&self) -> io::Result<()> {
37 cvt(libc::ioctl(self.fd, libc::FIOCLEX))?;
43 #[cfg(any(target_env = "newlib",
44 target_os = "solaris",
45 @@ -180,6 +186,7 @@ impl FileDesc {
47 target_os = "haiku"))]
48 pub fn set_cloexec(&self) -> io::Result<()> {
51 let previous = cvt(libc::fcntl(self.fd, libc::F_GETFD))?;
52 let new = previous | libc::FD_CLOEXEC;
53 @@ -188,19 +195,25 @@ impl FileDesc {
61 #[cfg(target_os = "linux")]
62 pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
65 let v = nonblocking as c_int;
66 cvt(libc::ioctl(self.fd, libc::FIONBIO, &v))?;
73 #[cfg(not(target_os = "linux"))]
74 pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
77 let previous = cvt(libc::fcntl(self.fd, libc::F_GETFL))?;
78 let new = if nonblocking {
79 @@ -213,9 +226,12 @@ impl FileDesc {
87 pub fn duplicate(&self) -> io::Result<FileDesc> {
89 // We want to atomically duplicate this file descriptor and set the
90 // CLOEXEC flag, and currently that's done via F_DUPFD_CLOEXEC. This
91 // flag, however, isn't supported on older Linux kernels (earlier than
92 @@ -263,6 +279,8 @@ impl FileDesc {
95 cvt(unsafe { libc::fcntl(fd, libc::F_DUPFD, 0) }).and_then(make_filedesc)
101 diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs
102 index add06ae..1a392fc 100644
103 --- a/src/libstd/sys/unix/fs.rs
104 +++ b/src/libstd/sys/unix/fs.rs
105 @@ -465,6 +465,7 @@ impl File {
108 pub fn open_c(path: &CStr, opts: &OpenOptions) -> io::Result<File> {
110 let flags = libc::O_CLOEXEC |
111 opts.get_access_mode()? |
112 opts.get_creation_mode()? |
113 @@ -519,6 +520,8 @@ impl File {
115 ensure_cloexec(&fd)?;
121 pub fn file_attr(&self) -> io::Result<FileAttr> {
122 @@ -535,6 +538,7 @@ impl File {
125 pub fn datasync(&self) -> io::Result<()> {
127 cvt_r(|| unsafe { os_datasync(self.0.raw()) })?;
130 @@ -547,7 +551,9 @@ impl File {
131 #[cfg(not(any(target_os = "macos",
133 target_os = "linux")))]
134 - unsafe fn os_datasync(fd: c_int) -> c_int { libc::fsync(fd) }
135 + unsafe fn os_datasync(fd: c_int) -> c_int { libc::fsync(fd) }]
140 pub fn truncate(&self, size: u64) -> io::Result<()> {
141 @@ -643,6 +649,7 @@ impl fmt::Debug for File {
143 #[cfg(target_os = "macos")]
144 fn get_path(fd: c_int) -> Option<PathBuf> {
146 // FIXME: The use of PATH_MAX is generally not encouraged, but it
147 // is inevitable in this case because macOS defines `fcntl` with
148 // `F_GETPATH` in terms of `MAXPATHLEN`, and there are no
149 @@ -657,6 +664,8 @@ impl fmt::Debug for File {
150 buf.truncate(l as usize);
152 Some(PathBuf::from(OsString::from_vec(buf)))
157 #[cfg(not(any(target_os = "linux", target_os = "macos")))]
158 @@ -667,6 +676,7 @@ impl fmt::Debug for File {
160 #[cfg(any(target_os = "linux", target_os = "macos"))]
161 fn get_mode(fd: c_int) -> Option<(bool, bool)> {
163 let mode = unsafe { libc::fcntl(fd, libc::F_GETFL) };
166 @@ -677,6 +687,8 @@ impl fmt::Debug for File {
167 libc::O_WRONLY => Some((false, true)),
174 #[cfg(not(any(target_os = "linux", target_os = "macos")))]
175 @@ -868,6 +880,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
181 libc::SYS_copy_file_range,
183 @@ -877,6 +890,8 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
192 diff --git a/src/libstd/sys/unix/net.rs b/src/libstd/sys/unix/net.rs
193 index 2d10541..19e96c4 100644
194 --- a/src/libstd/sys/unix/net.rs
195 +++ b/src/libstd/sys/unix/net.rs
196 @@ -339,8 +339,11 @@ impl Socket {
199 pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
201 let mut nonblocking = nonblocking as libc::c_int;
202 cvt(unsafe { libc::ioctl(*self.as_inner(), libc::FIONBIO, &mut nonblocking) }).map(|_| ())
207 pub fn take_error(&self) -> io::Result<Option<io::Error>> {
208 diff --git a/src/libstd/sys/unix/rand.rs b/src/libstd/sys/unix/rand.rs
209 index 371e58a..28d4c68 100644
210 --- a/src/libstd/sys/unix/rand.rs
211 +++ b/src/libstd/sys/unix/rand.rs
212 @@ -34,9 +34,12 @@ mod imp {
214 #[cfg(any(target_os = "linux", target_os = "android"))]
215 fn getrandom(buf: &mut [u8]) -> libc::c_long {
218 libc::syscall(libc::SYS_getrandom, buf.as_mut_ptr(), buf.len(), libc::GRND_NONBLOCK)
224 #[cfg(not(any(target_os = "linux", target_os = "android")))]
225 diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs
226 index f3a45d2..1c2f0ce 100644
227 --- a/src/libstd/sys/unix/thread.rs
228 +++ b/src/libstd/sys/unix/thread.rs
229 @@ -100,12 +100,15 @@ impl Thread {
230 #[cfg(any(target_os = "linux",
231 target_os = "android"))]
232 pub fn set_name(name: &CStr) {
234 const PR_SET_NAME: libc::c_int = 15;
235 // pthread wrapper only appeared in glibc 2.12, so we use syscall
238 libc::prctl(PR_SET_NAME, name.as_ptr() as libc::c_ulong, 0, 0, 0);
244 #[cfg(any(target_os = "freebsd",
246 2.17.2 (Apple Git-113)