Skip to content

Commit 183329c

Browse files
committed
Auto merge of #44707 - GuillaumeGomez:rollup, r=arielb1
Rollup of 5 pull requests - Successful merges: #44513, #44626, #44689, #44693, #44703 - Failed merges:
2 parents 94a82ad + bfed2dc commit 183329c

File tree

10 files changed

+228
-32
lines changed

10 files changed

+228
-32
lines changed

src/librustc/session/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1332,7 +1332,7 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
13321332
print on stdout",
13331333
"[crate-name|file-names|sysroot|cfg|target-list|\
13341334
target-cpus|target-features|relocation-models|\
1335-
code-models|target-spec-json|native-static-deps]"),
1335+
code-models|target-spec-json|native-static-libs]"),
13361336
opt::flagmulti_s("g", "", "Equivalent to -C debuginfo=2"),
13371337
opt::flagmulti_s("O", "", "Equivalent to -C opt-level=2"),
13381338
opt::opt_s("o", "", "Write output to <filename>", "FILENAME"),

src/librustc_trans/back/linker.rs

+12
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,18 @@ impl<'a> Linker for MsvcLinker<'a> {
496496
let sysroot = self.sess.sysroot();
497497
let natvis_dir_path = sysroot.join("lib\\rustlib\\etc");
498498
if let Ok(natvis_dir) = fs::read_dir(&natvis_dir_path) {
499+
// LLVM 5.0.0's lld-link frontend doesn't yet recognize, and chokes
500+
// on, the /NATVIS:... flags. LLVM 6 (or earlier) should at worst ignore
501+
// them, eventually mooting this workaround, per this landed patch:
502+
// https://github.com/llvm-mirror/lld/commit/27b9c4285364d8d76bb43839daa100
503+
if let Some(ref linker_path) = self.sess.opts.cg.linker {
504+
if let Some(linker_name) = Path::new(&linker_path).file_stem() {
505+
if linker_name.to_str().unwrap().to_lowercase() == "lld-link" {
506+
self.sess.warn("not embedding natvis: lld-link may not support the flag");
507+
return;
508+
}
509+
}
510+
}
499511
for entry in natvis_dir {
500512
match entry {
501513
Ok(entry) => {

src/libstd/io/util.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,18 @@ pub fn copy<R: ?Sized, W: ?Sized>(reader: &mut R, writer: &mut W) -> io::Result<
6969

7070
/// A reader which is always at EOF.
7171
///
72-
/// This struct is generally created by calling [`empty`][empty]. Please see
73-
/// the documentation of `empty()` for more details.
72+
/// This struct is generally created by calling [`empty`]. Please see
73+
/// the documentation of [`empty()`][`empty`] for more details.
7474
///
75-
/// [empty]: fn.empty.html
75+
/// [`empty`]: fn.empty.html
7676
#[stable(feature = "rust1", since = "1.0.0")]
7777
pub struct Empty { _priv: () }
7878

7979
/// Constructs a new handle to an empty reader.
8080
///
81-
/// All reads from the returned reader will return `Ok(0)`.
81+
/// All reads from the returned reader will return [`Ok`]`(0)`.
82+
///
83+
/// [`Ok`]: ../result/enum.Result.html#variant.Ok
8284
///
8385
/// # Examples
8486
///

src/libstd/sys/redox/net/netc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ pub type in_port_t = u16;
1414
pub type socklen_t = u32;
1515
pub type sa_family_t = u16;
1616

17-
pub const AF_INET: sa_family_t = 1;
18-
pub const AF_INET6: sa_family_t = 2;
17+
pub const AF_INET: sa_family_t = 2;
18+
pub const AF_INET6: sa_family_t = 23;
1919

2020
#[derive(Copy, Clone)]
2121
#[repr(C)]

src/libstd/sys/redox/syscall/call.rs

+53-12
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@
99
// except according to those terms.
1010

1111
use super::arch::*;
12-
use super::data::{Stat, StatVfs, TimeSpec};
12+
use super::data::{SigAction, Stat, StatVfs, TimeSpec};
1313
use super::error::Result;
1414
use super::number::*;
1515

16-
use core::mem;
16+
use core::{mem, ptr};
17+
18+
// Signal restorer
19+
extern "C" fn restorer() -> ! {
20+
sigreturn().unwrap();
21+
unreachable!();
22+
}
1723

1824
/// Set the end of the process's heap
1925
///
@@ -43,12 +49,12 @@ pub unsafe fn brk(addr: usize) -> Result<usize> {
4349
/// * `EIO` - an I/O error occurred
4450
/// * `ENOENT` - `path` does not exit
4551
/// * `ENOTDIR` - `path` is not a directory
46-
pub fn chdir(path: &str) -> Result<usize> {
47-
unsafe { syscall2(SYS_CHDIR, path.as_ptr() as usize, path.len()) }
52+
pub fn chdir<T: AsRef<[u8]>>(path: T) -> Result<usize> {
53+
unsafe { syscall2(SYS_CHDIR, path.as_ref().as_ptr() as usize, path.as_ref().len()) }
4854
}
4955

50-
pub fn chmod(path: &str, mode: usize) -> Result<usize> {
51-
unsafe { syscall3(SYS_CHMOD, path.as_ptr() as usize, path.len(), mode) }
56+
pub fn chmod<T: AsRef<[u8]>>(path: T, mode: usize) -> Result<usize> {
57+
unsafe { syscall3(SYS_CHMOD, path.as_ref().as_ptr() as usize, path.as_ref().len(), mode) }
5258
}
5359

5460
/// Produce a fork of the current process, or a new process thread
@@ -132,6 +138,12 @@ pub fn ftruncate(fd: usize, len: usize) -> Result<usize> {
132138
unsafe { syscall2(SYS_FTRUNCATE, fd, len) }
133139
}
134140

141+
// Change modify and/or access times
142+
pub fn futimens(fd: usize, times: &[TimeSpec]) -> Result<usize> {
143+
unsafe { syscall3(SYS_FUTIMENS, fd, times.as_ptr() as usize,
144+
times.len() * mem::size_of::<TimeSpec>()) }
145+
}
146+
135147
/// Fast userspace mutex
136148
pub unsafe fn futex(addr: *mut i32, op: usize, val: i32, val2: usize, addr2: *mut i32)
137149
-> Result<usize> {
@@ -173,6 +185,16 @@ pub fn getpid() -> Result<usize> {
173185
unsafe { syscall0(SYS_GETPID) }
174186
}
175187

188+
/// Get the process group ID
189+
pub fn getpgid(pid: usize) -> Result<usize> {
190+
unsafe { syscall1(SYS_GETPGID, pid) }
191+
}
192+
193+
/// Get the parent process ID
194+
pub fn getppid() -> Result<usize> {
195+
unsafe { syscall0(SYS_GETPPID) }
196+
}
197+
176198
/// Get the current user ID
177199
pub fn getuid() -> Result<usize> {
178200
unsafe { syscall0(SYS_GETUID) }
@@ -210,8 +232,8 @@ pub fn nanosleep(req: &TimeSpec, rem: &mut TimeSpec) -> Result<usize> {
210232
}
211233

212234
/// Open a file
213-
pub fn open(path: &str, flags: usize) -> Result<usize> {
214-
unsafe { syscall3(SYS_OPEN, path.as_ptr() as usize, path.len(), flags) }
235+
pub fn open<T: AsRef<[u8]>>(path: T, flags: usize) -> Result<usize> {
236+
unsafe { syscall3(SYS_OPEN, path.as_ref().as_ptr() as usize, path.as_ref().len(), flags) }
215237
}
216238

217239
/// Allocate pages, linearly in physical memory
@@ -245,8 +267,13 @@ pub fn read(fd: usize, buf: &mut [u8]) -> Result<usize> {
245267
}
246268

247269
/// Remove a directory
248-
pub fn rmdir(path: &str) -> Result<usize> {
249-
unsafe { syscall2(SYS_RMDIR, path.as_ptr() as usize, path.len()) }
270+
pub fn rmdir<T: AsRef<[u8]>>(path: T) -> Result<usize> {
271+
unsafe { syscall2(SYS_RMDIR, path.as_ref().as_ptr() as usize, path.as_ref().len()) }
272+
}
273+
274+
/// Set the process group ID
275+
pub fn setpgid(pid: usize, pgid: usize) -> Result<usize> {
276+
unsafe { syscall2(SYS_SETPGID, pid, pgid) }
250277
}
251278

252279
/// Set the current process group IDs
@@ -264,9 +291,23 @@ pub fn setreuid(ruid: usize, euid: usize) -> Result<usize> {
264291
unsafe { syscall2(SYS_SETREUID, ruid, euid) }
265292
}
266293

294+
/// Set up a signal handler
295+
pub fn sigaction(sig: usize, act: Option<&SigAction>, oldact: Option<&mut SigAction>)
296+
-> Result<usize> {
297+
unsafe { syscall4(SYS_SIGACTION, sig,
298+
act.map(|x| x as *const _).unwrap_or_else(ptr::null) as usize,
299+
oldact.map(|x| x as *mut _).unwrap_or_else(ptr::null_mut) as usize,
300+
restorer as usize) }
301+
}
302+
303+
// Return from signal handler
304+
pub fn sigreturn() -> Result<usize> {
305+
unsafe { syscall0(SYS_SIGRETURN) }
306+
}
307+
267308
/// Remove a file
268-
pub fn unlink(path: &str) -> Result<usize> {
269-
unsafe { syscall2(SYS_UNLINK, path.as_ptr() as usize, path.len()) }
309+
pub fn unlink<T: AsRef<[u8]>>(path: T) -> Result<usize> {
310+
unsafe { syscall2(SYS_UNLINK, path.as_ref().as_ptr() as usize, path.as_ref().len()) }
270311
}
271312

272313
/// Convert a virtual address to a physical one

src/libstd/sys/redox/syscall/data.rs

+108-12
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,90 @@
1111
use core::ops::{Deref, DerefMut};
1212
use core::{mem, slice};
1313

14+
#[derive(Copy, Clone, Debug, Default)]
15+
pub struct Event {
16+
pub id: usize,
17+
pub flags: usize,
18+
pub data: usize
19+
}
20+
21+
impl Deref for Event {
22+
type Target = [u8];
23+
fn deref(&self) -> &[u8] {
24+
unsafe {
25+
slice::from_raw_parts(
26+
self as *const Event as *const u8,
27+
mem::size_of::<Event>()
28+
) as &[u8]
29+
}
30+
}
31+
}
32+
33+
impl DerefMut for Event {
34+
fn deref_mut(&mut self) -> &mut [u8] {
35+
unsafe {
36+
slice::from_raw_parts_mut(
37+
self as *mut Event as *mut u8,
38+
mem::size_of::<Event>()
39+
) as &mut [u8]
40+
}
41+
}
42+
}
43+
44+
#[derive(Copy, Clone, Debug, Default)]
45+
#[repr(C)]
46+
pub struct Packet {
47+
pub id: u64,
48+
pub pid: usize,
49+
pub uid: u32,
50+
pub gid: u32,
51+
pub a: usize,
52+
pub b: usize,
53+
pub c: usize,
54+
pub d: usize
55+
}
56+
57+
impl Deref for Packet {
58+
type Target = [u8];
59+
fn deref(&self) -> &[u8] {
60+
unsafe {
61+
slice::from_raw_parts(
62+
self as *const Packet as *const u8,
63+
mem::size_of::<Packet>()
64+
) as &[u8]
65+
}
66+
}
67+
}
68+
69+
impl DerefMut for Packet {
70+
fn deref_mut(&mut self) -> &mut [u8] {
71+
unsafe {
72+
slice::from_raw_parts_mut(
73+
self as *mut Packet as *mut u8,
74+
mem::size_of::<Packet>()
75+
) as &mut [u8]
76+
}
77+
}
78+
}
79+
80+
#[derive(Copy, Clone, Debug)]
81+
#[repr(C)]
82+
pub struct SigAction {
83+
pub sa_handler: extern "C" fn(usize),
84+
pub sa_mask: [u64; 2],
85+
pub sa_flags: usize,
86+
}
87+
88+
impl Default for SigAction {
89+
fn default() -> Self {
90+
Self {
91+
sa_handler: unsafe { mem::transmute(0usize) },
92+
sa_mask: [0; 2],
93+
sa_flags: 0,
94+
}
95+
}
96+
}
97+
1498
#[derive(Copy, Clone, Debug, Default)]
1599
#[repr(C)]
16100
pub struct Stat {
@@ -35,17 +119,21 @@ impl Deref for Stat {
35119
type Target = [u8];
36120
fn deref(&self) -> &[u8] {
37121
unsafe {
38-
slice::from_raw_parts(self as *const Stat as *const u8,
39-
mem::size_of::<Stat>()) as &[u8]
122+
slice::from_raw_parts(
123+
self as *const Stat as *const u8,
124+
mem::size_of::<Stat>()
125+
) as &[u8]
40126
}
41127
}
42128
}
43129

44130
impl DerefMut for Stat {
45131
fn deref_mut(&mut self) -> &mut [u8] {
46132
unsafe {
47-
slice::from_raw_parts_mut(self as *mut Stat as *mut u8,
48-
mem::size_of::<Stat>()) as &mut [u8]
133+
slice::from_raw_parts_mut(
134+
self as *mut Stat as *mut u8,
135+
mem::size_of::<Stat>()
136+
) as &mut [u8]
49137
}
50138
}
51139
}
@@ -63,17 +151,21 @@ impl Deref for StatVfs {
63151
type Target = [u8];
64152
fn deref(&self) -> &[u8] {
65153
unsafe {
66-
slice::from_raw_parts(self as *const StatVfs as *const u8,
67-
mem::size_of::<StatVfs>()) as &[u8]
154+
slice::from_raw_parts(
155+
self as *const StatVfs as *const u8,
156+
mem::size_of::<StatVfs>()
157+
) as &[u8]
68158
}
69159
}
70160
}
71161

72162
impl DerefMut for StatVfs {
73163
fn deref_mut(&mut self) -> &mut [u8] {
74164
unsafe {
75-
slice::from_raw_parts_mut(self as *mut StatVfs as *mut u8,
76-
mem::size_of::<StatVfs>()) as &mut [u8]
165+
slice::from_raw_parts_mut(
166+
self as *mut StatVfs as *mut u8,
167+
mem::size_of::<StatVfs>()
168+
) as &mut [u8]
77169
}
78170
}
79171
}
@@ -89,17 +181,21 @@ impl Deref for TimeSpec {
89181
type Target = [u8];
90182
fn deref(&self) -> &[u8] {
91183
unsafe {
92-
slice::from_raw_parts(self as *const TimeSpec as *const u8,
93-
mem::size_of::<TimeSpec>()) as &[u8]
184+
slice::from_raw_parts(
185+
self as *const TimeSpec as *const u8,
186+
mem::size_of::<TimeSpec>()
187+
) as &[u8]
94188
}
95189
}
96190
}
97191

98192
impl DerefMut for TimeSpec {
99193
fn deref_mut(&mut self) -> &mut [u8] {
100194
unsafe {
101-
slice::from_raw_parts_mut(self as *mut TimeSpec as *mut u8,
102-
mem::size_of::<TimeSpec>()) as &mut [u8]
195+
slice::from_raw_parts_mut(
196+
self as *mut TimeSpec as *mut u8,
197+
mem::size_of::<TimeSpec>()
198+
) as &mut [u8]
103199
}
104200
}
105201
}

src/libstd/sys/redox/syscall/flag.rs

+17
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
pub const CLONE_VM: usize = 0x100;
1212
pub const CLONE_FS: usize = 0x200;
1313
pub const CLONE_FILES: usize = 0x400;
14+
pub const CLONE_SIGHAND: usize = 0x800;
1415
pub const CLONE_VFORK: usize = 0x4000;
16+
pub const CLONE_THREAD: usize = 0x10000;
1517

1618
pub const CLOCK_REALTIME: usize = 1;
1719
pub const CLOCK_MONOTONIC: usize = 4;
@@ -20,6 +22,7 @@ pub const EVENT_NONE: usize = 0;
2022
pub const EVENT_READ: usize = 1;
2123
pub const EVENT_WRITE: usize = 2;
2224

25+
pub const F_DUPFD: usize = 0;
2326
pub const F_GETFD: usize = 1;
2427
pub const F_SETFD: usize = 2;
2528
pub const F_GETFL: usize = 3;
@@ -36,6 +39,8 @@ pub const MODE_TYPE: u16 = 0xF000;
3639
pub const MODE_DIR: u16 = 0x4000;
3740
pub const MODE_FILE: u16 = 0x8000;
3841
pub const MODE_SYMLINK: u16 = 0xA000;
42+
pub const MODE_FIFO: u16 = 0x1000;
43+
pub const MODE_CHR: u16 = 0x2000;
3944

4045
pub const MODE_PERM: u16 = 0x0FFF;
4146
pub const MODE_SETUID: u16 = 0o4000;
@@ -96,4 +101,16 @@ pub const SIGIO: usize = 29;
96101
pub const SIGPWR: usize = 30;
97102
pub const SIGSYS: usize = 31;
98103

104+
pub const SIG_DFL: usize = 0;
105+
pub const SIG_IGN: usize = 1;
106+
107+
pub const SA_NOCLDSTOP: usize = 0x00000001;
108+
pub const SA_NOCLDWAIT: usize = 0x00000002;
109+
pub const SA_SIGINFO: usize = 0x00000004;
110+
pub const SA_RESTORER: usize = 0x04000000;
111+
pub const SA_ONSTACK: usize = 0x08000000;
112+
pub const SA_RESTART: usize = 0x10000000;
113+
pub const SA_NODEFER: usize = 0x40000000;
114+
pub const SA_RESETHAND: usize = 0x80000000;
115+
99116
pub const WNOHANG: usize = 1;

0 commit comments

Comments
 (0)