Skip to content

Commit 746222f

Browse files
committed
Switch to using syscall crate directly - without import
1 parent d73d32f commit 746222f

File tree

15 files changed

+171
-188
lines changed

15 files changed

+171
-188
lines changed

src/libstd/sys/redox/condvar.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ use intrinsics::{atomic_cxchg, atomic_xadd, atomic_xchg};
33
use ptr;
44
use time::Duration;
55

6-
use super::mutex::{mutex_lock, mutex_unlock, Mutex};
7-
8-
use libc::{futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_REQUEUE};
6+
use sys::mutex::{mutex_lock, mutex_unlock, Mutex};
7+
use sys::syscall::{futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_REQUEUE};
98

109
pub struct Condvar {
1110
lock: UnsafeCell<*mut i32>,

src/libstd/sys/redox/ext/fs.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ impl MetadataExt for fs::Metadata {
216216
}
217217
}
218218

219-
/* TODO
220219
/// Add special unix types (block/char device, fifo and socket)
221220
#[stable(feature = "file_type_ext", since = "1.5.0")]
222221
pub trait FileTypeExt {
@@ -236,12 +235,11 @@ pub trait FileTypeExt {
236235

237236
#[stable(feature = "file_type_ext", since = "1.5.0")]
238237
impl FileTypeExt for fs::FileType {
239-
fn is_block_device(&self) -> bool { self.as_inner().is(libc::S_IFBLK) }
240-
fn is_char_device(&self) -> bool { self.as_inner().is(libc::S_IFCHR) }
241-
fn is_fifo(&self) -> bool { self.as_inner().is(libc::S_IFIFO) }
242-
fn is_socket(&self) -> bool { self.as_inner().is(libc::S_IFSOCK) }
238+
fn is_block_device(&self) -> bool { false /*TODO*/ }
239+
fn is_char_device(&self) -> bool { false /*TODO*/ }
240+
fn is_fifo(&self) -> bool { false /*TODO*/ }
241+
fn is_socket(&self) -> bool { false /*TODO*/ }
243242
}
244-
*/
245243

246244
/// Creates a new symbolic link on the filesystem.
247245
///

src/libstd/sys/redox/ext/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub mod prelude {
4444
#[doc(no_inline)] #[stable(feature = "rust1", since = "1.0.0")]
4545
pub use super::ffi::{OsStrExt, OsStringExt};
4646
#[doc(no_inline)] #[stable(feature = "rust1", since = "1.0.0")]
47-
pub use super::fs::{PermissionsExt, OpenOptionsExt, MetadataExt};
47+
pub use super::fs::{FileTypeExt, PermissionsExt, OpenOptionsExt, MetadataExt};
4848
#[doc(no_inline)] #[stable(feature = "rust1", since = "1.0.0")]
4949
pub use super::process::{CommandExt, ExitStatusExt};
5050
}

src/libstd/sys/redox/ext/process.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ pub trait CommandExt {
8686
#[stable(feature = "rust1", since = "1.0.0")]
8787
impl CommandExt for process::Command {
8888
fn uid(&mut self, id: u32) -> &mut process::Command {
89-
self.as_inner_mut().uid(id as usize);
89+
self.as_inner_mut().uid(id);
9090
self
9191
}
9292

9393
fn gid(&mut self, id: u32) -> &mut process::Command {
94-
self.as_inner_mut().gid(id as usize);
94+
self.as_inner_mut().gid(id);
9595
self
9696
}
9797

src/libstd/sys/redox/fd.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
#![unstable(reason = "not public", issue = "0", feature = "fd")]
1212

1313
use io::{self, Read};
14-
use libc;
1514
use mem;
16-
use sys::cvt;
15+
use sys::{cvt, syscall};
1716
use sys_common::AsInner;
1817
use sys_common::io::read_to_end_uninitialized;
1918

@@ -36,7 +35,7 @@ impl FileDesc {
3635
}
3736

3837
pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> {
39-
cvt(libc::read(self.fd, buf))
38+
cvt(syscall::read(self.fd, buf))
4039
}
4140

4241
pub fn read_to_end(&self, buf: &mut Vec<u8>) -> io::Result<usize> {
@@ -45,33 +44,33 @@ impl FileDesc {
4544
}
4645

4746
pub fn write(&self, buf: &[u8]) -> io::Result<usize> {
48-
cvt(libc::write(self.fd, buf))
47+
cvt(syscall::write(self.fd, buf))
4948
}
5049

5150
pub fn duplicate(&self) -> io::Result<FileDesc> {
52-
let new_fd = cvt(libc::dup(self.fd, &[]))?;
51+
let new_fd = cvt(syscall::dup(self.fd, &[]))?;
5352
Ok(FileDesc::new(new_fd))
5453
}
5554

5655
pub fn nonblocking(&self) -> io::Result<bool> {
57-
let flags = cvt(libc::fcntl(self.fd, libc::F_GETFL, 0))?;
58-
Ok(flags & libc::O_NONBLOCK == libc::O_NONBLOCK)
56+
let flags = cvt(syscall::fcntl(self.fd, syscall::F_GETFL, 0))?;
57+
Ok(flags & syscall::O_NONBLOCK == syscall::O_NONBLOCK)
5958
}
6059

6160
pub fn set_cloexec(&self) -> io::Result<()> {
62-
let mut flags = cvt(libc::fcntl(self.fd, libc::F_GETFL, 0))?;
63-
flags |= libc::O_CLOEXEC;
64-
cvt(libc::fcntl(self.fd, libc::F_SETFL, flags)).and(Ok(()))
61+
let mut flags = cvt(syscall::fcntl(self.fd, syscall::F_GETFL, 0))?;
62+
flags |= syscall::O_CLOEXEC;
63+
cvt(syscall::fcntl(self.fd, syscall::F_SETFL, flags)).and(Ok(()))
6564
}
6665

6766
pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
68-
let mut flags = cvt(libc::fcntl(self.fd, libc::F_GETFL, 0))?;
67+
let mut flags = cvt(syscall::fcntl(self.fd, syscall::F_GETFL, 0))?;
6968
if nonblocking {
70-
flags |= libc::O_NONBLOCK;
69+
flags |= syscall::O_NONBLOCK;
7170
} else {
72-
flags &= !libc::O_NONBLOCK;
71+
flags &= !syscall::O_NONBLOCK;
7372
}
74-
cvt(libc::fcntl(self.fd, libc::F_SETFL, flags)).and(Ok(()))
73+
cvt(syscall::fcntl(self.fd, syscall::F_SETFL, flags)).and(Ok(()))
7574
}
7675
}
7776

@@ -96,6 +95,6 @@ impl Drop for FileDesc {
9695
// the file descriptor was closed or not, and if we retried (for
9796
// something like EINTR), we might close another valid file descriptor
9897
// (opened after we closed ours.
99-
let _ = libc::close(self.fd);
98+
let _ = syscall::close(self.fd);
10099
}
101100
}

0 commit comments

Comments
 (0)