Skip to content

Commit e8e6892

Browse files
committed
Auto merge of #29289 - DiamondLovesYou:pnacl-std-crates, r=alexcrichton
2 parents b4af35f + a7d93c9 commit e8e6892

File tree

16 files changed

+273
-299
lines changed

16 files changed

+273
-299
lines changed

src/libstd/dynamic_lib.rs

+28-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl DynamicLibrary {
120120
}
121121
}
122122

123-
#[cfg(all(test, not(target_os = "ios")))]
123+
#[cfg(all(test, not(target_os = "ios"), not(target_os = "nacl")))]
124124
mod tests {
125125
use super::*;
126126
use prelude::v1::*;
@@ -374,3 +374,30 @@ mod dl {
374374
fn SetErrorMode(uMode: libc::c_uint) -> libc::c_uint;
375375
}
376376
}
377+
378+
#[cfg(target_os = "nacl")]
379+
pub mod dl {
380+
use ffi::OsStr;
381+
use ptr;
382+
use result::Result;
383+
use result::Result::Err;
384+
use libc;
385+
use string::String;
386+
use ops::FnOnce;
387+
use option::Option;
388+
389+
pub fn open(_filename: Option<&OsStr>) -> Result<*mut u8, String> {
390+
Err(format!("NaCl + Newlib doesn't impl loading shared objects"))
391+
}
392+
393+
pub fn check_for_errors_in<T, F>(_f: F) -> Result<T, String>
394+
where F: FnOnce() -> T,
395+
{
396+
Err(format!("NaCl doesn't support shared objects"))
397+
}
398+
399+
pub unsafe fn symbol(_handle: *mut u8, _symbol: *const libc::c_char) -> *mut u8 {
400+
ptr::null_mut()
401+
}
402+
pub unsafe fn close(_handle: *mut u8) { }
403+
}

src/libstd/env.rs

+26
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,27 @@ mod os {
807807
pub const EXE_EXTENSION: &'static str = "exe";
808808
}
809809

810+
#[cfg(all(target_os = "nacl", not(target_arch = "le32")))]
811+
mod os {
812+
pub const FAMILY: &'static str = "unix";
813+
pub const OS: &'static str = "nacl";
814+
pub const DLL_PREFIX: &'static str = "lib";
815+
pub const DLL_SUFFIX: &'static str = ".so";
816+
pub const DLL_EXTENSION: &'static str = "so";
817+
pub const EXE_SUFFIX: &'static str = ".nexe";
818+
pub const EXE_EXTENSION: &'static str = "nexe";
819+
}
820+
#[cfg(all(target_os = "nacl", target_arch = "le32"))]
821+
mod os {
822+
pub const FAMILY: &'static str = "unix";
823+
pub const OS: &'static str = "pnacl";
824+
pub const DLL_PREFIX: &'static str = "lib";
825+
pub const DLL_SUFFIX: &'static str = ".pso";
826+
pub const DLL_EXTENSION: &'static str = "pso";
827+
pub const EXE_SUFFIX: &'static str = ".pexe";
828+
pub const EXE_EXTENSION: &'static str = "pexe";
829+
}
830+
810831
#[cfg(target_arch = "x86")]
811832
mod arch {
812833
pub const ARCH: &'static str = "x86";
@@ -842,6 +863,11 @@ mod arch {
842863
pub const ARCH: &'static str = "powerpc";
843864
}
844865

866+
#[cfg(target_arch = "le32")]
867+
mod arch {
868+
pub const ARCH: &'static str = "le32";
869+
}
870+
845871
#[cfg(test)]
846872
mod tests {
847873
use prelude::v1::*;

src/libstd/os/nacl/raw.rs

+30-239
Original file line numberDiff line numberDiff line change
@@ -12,245 +12,36 @@
1212
1313
#![stable(feature = "raw_ext", since = "1.1.0")]
1414

15+
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32;
16+
#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i32;
1517
#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64;
18+
#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u32;
19+
#[stable(feature = "raw_ext", since = "1.1.0")] pub type pid_t = i32;
20+
#[stable(feature = "raw_ext", since = "1.1.0")] pub type uid_t = u32;
21+
#[stable(feature = "raw_ext", since = "1.1.0")] pub type gid_t = u32;
1622
#[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32;
17-
18-
pub use self::arch::{off_t, ino_t, nlink_t, blksize_t, blkcnt_t, stat, time_t};
19-
20-
#[cfg(any(target_arch = "x86",
21-
target_arch = "le32",
22-
target_arch = "powerpc",
23-
target_arch = "arm"))]
24-
mod arch {
25-
use super::{dev_t, mode_t};
26-
use os::raw::{c_long, c_short};
27-
use os::unix::raw::{gid_t, uid_t};
28-
29-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i32;
30-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i32;
31-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u32;
32-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u32;
33-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i32;
34-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32;
35-
36-
#[repr(C)]
37-
#[derive(Clone)]
38-
#[stable(feature = "raw_ext", since = "1.1.0")]
39-
pub struct stat {
40-
#[stable(feature = "raw_ext", since = "1.1.0")]
41-
pub st_dev: dev_t,
42-
#[stable(feature = "raw_ext", since = "1.1.0")]
43-
pub __pad1: c_short,
44-
#[stable(feature = "raw_ext", since = "1.1.0")]
45-
pub st_ino: ino_t,
46-
#[stable(feature = "raw_ext", since = "1.1.0")]
47-
pub st_mode: mode_t,
48-
#[stable(feature = "raw_ext", since = "1.1.0")]
49-
pub st_nlink: nlink_t,
50-
#[stable(feature = "raw_ext", since = "1.1.0")]
51-
pub st_uid: uid_t,
52-
#[stable(feature = "raw_ext", since = "1.1.0")]
53-
pub st_gid: gid_t,
54-
#[stable(feature = "raw_ext", since = "1.1.0")]
55-
pub st_rdev: dev_t,
56-
#[stable(feature = "raw_ext", since = "1.1.0")]
57-
pub __pad2: c_short,
58-
#[stable(feature = "raw_ext", since = "1.1.0")]
59-
pub st_size: off_t,
60-
#[stable(feature = "raw_ext", since = "1.1.0")]
61-
pub st_blksize: blksize_t,
62-
#[stable(feature = "raw_ext", since = "1.1.0")]
63-
pub st_blocks: blkcnt_t,
64-
#[stable(feature = "raw_ext", since = "1.1.0")]
65-
pub st_atime: time_t,
66-
#[stable(feature = "raw_ext", since = "1.1.0")]
67-
pub st_atime_nsec: c_long,
68-
#[stable(feature = "raw_ext", since = "1.1.0")]
69-
pub st_mtime: time_t,
70-
#[stable(feature = "raw_ext", since = "1.1.0")]
71-
pub st_mtime_nsec: c_long,
72-
#[stable(feature = "raw_ext", since = "1.1.0")]
73-
pub st_ctime: time_t,
74-
#[stable(feature = "raw_ext", since = "1.1.0")]
75-
pub st_ctime_nsec: c_long,
76-
#[stable(feature = "raw_ext", since = "1.1.0")]
77-
pub __unused4: c_long,
78-
#[stable(feature = "raw_ext", since = "1.1.0")]
79-
pub __unused5: c_long,
80-
}
81-
}
82-
83-
#[cfg(any(target_arch = "mips",
84-
target_arch = "mipsel"))]
85-
mod arch {
86-
use super::{dev_t, mode_t};
87-
use os::raw::c_long;
88-
use os::unix::raw::{gid_t, uid_t};
89-
90-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i32;
91-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i32;
92-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u32;
93-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u32;
94-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i32;
95-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32;
96-
97-
#[repr(C)]
98-
#[derive(Clone)]
99-
#[stable(feature = "raw_ext", since = "1.1.0")]
100-
pub struct stat {
101-
#[stable(feature = "raw_ext", since = "1.1.0")]
102-
pub st_dev: c_ulong,
103-
#[stable(feature = "raw_ext", since = "1.1.0")]
104-
pub st_pad1: [c_long; 3],
105-
#[stable(feature = "raw_ext", since = "1.1.0")]
106-
pub st_ino: ino_t,
107-
#[stable(feature = "raw_ext", since = "1.1.0")]
108-
pub st_mode: mode_t,
109-
#[stable(feature = "raw_ext", since = "1.1.0")]
110-
pub st_nlink: nlink_t,
111-
#[stable(feature = "raw_ext", since = "1.1.0")]
112-
pub st_uid: uid_t,
113-
#[stable(feature = "raw_ext", since = "1.1.0")]
114-
pub st_gid: gid_t,
115-
#[stable(feature = "raw_ext", since = "1.1.0")]
116-
pub st_rdev: c_ulong,
117-
#[stable(feature = "raw_ext", since = "1.1.0")]
118-
pub st_pad2: [c_long; 2],
119-
#[stable(feature = "raw_ext", since = "1.1.0")]
120-
pub st_size: off_t,
121-
#[stable(feature = "raw_ext", since = "1.1.0")]
122-
pub st_pad3: c_long,
123-
#[stable(feature = "raw_ext", since = "1.1.0")]
124-
pub st_atime: time_t,
125-
#[stable(feature = "raw_ext", since = "1.1.0")]
126-
pub st_atime_nsec: c_long,
127-
#[stable(feature = "raw_ext", since = "1.1.0")]
128-
pub st_mtime: time_t,
129-
#[stable(feature = "raw_ext", since = "1.1.0")]
130-
pub st_mtime_nsec: c_long,
131-
#[stable(feature = "raw_ext", since = "1.1.0")]
132-
pub st_ctime: time_t,
133-
#[stable(feature = "raw_ext", since = "1.1.0")]
134-
pub st_ctime_nsec: c_long,
135-
#[stable(feature = "raw_ext", since = "1.1.0")]
136-
pub st_blksize: blksize_t,
137-
#[stable(feature = "raw_ext", since = "1.1.0")]
138-
pub st_blocks: blkcnt_t,
139-
#[stable(feature = "raw_ext", since = "1.1.0")]
140-
pub st_pad5: [c_long; 14],
141-
}
142-
}
143-
144-
#[cfg(target_arch = "aarch64")]
145-
mod arch {
146-
use super::{dev_t, mode_t};
147-
use os::raw::{c_long, c_int};
148-
use os::unix::raw::{gid_t, uid_t};
149-
150-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
151-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i32;
152-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
153-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u32;
154-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
155-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
156-
157-
#[repr(C)]
158-
#[derive(Clone)]
159-
#[stable(feature = "raw_ext", since = "1.1.0")]
160-
pub struct stat {
161-
#[stable(feature = "raw_ext", since = "1.1.0")]
162-
pub st_dev: dev_t,
163-
#[stable(feature = "raw_ext", since = "1.1.0")]
164-
pub st_ino: ino_t,
165-
#[stable(feature = "raw_ext", since = "1.1.0")]
166-
pub st_mode: mode_t,
167-
#[stable(feature = "raw_ext", since = "1.1.0")]
168-
pub st_nlink: nlink_t,
169-
#[stable(feature = "raw_ext", since = "1.1.0")]
170-
pub st_uid: uid_t,
171-
#[stable(feature = "raw_ext", since = "1.1.0")]
172-
pub st_gid: gid_t,
173-
#[stable(feature = "raw_ext", since = "1.1.0")]
174-
pub st_rdev: dev_t,
175-
#[stable(feature = "raw_ext", since = "1.1.0")]
176-
pub __pad1: dev_t,
177-
#[stable(feature = "raw_ext", since = "1.1.0")]
178-
pub st_size: off_t,
179-
#[stable(feature = "raw_ext", since = "1.1.0")]
180-
pub st_blksize: blksize_t,
181-
#[stable(feature = "raw_ext", since = "1.1.0")]
182-
pub __pad2: c_int,
183-
#[stable(feature = "raw_ext", since = "1.1.0")]
184-
pub st_blocks: blkcnt_t,
185-
#[stable(feature = "raw_ext", since = "1.1.0")]
186-
pub st_atime: time_t,
187-
#[stable(feature = "raw_ext", since = "1.1.0")]
188-
pub st_atime_nsec: c_long,
189-
#[stable(feature = "raw_ext", since = "1.1.0")]
190-
pub st_mtime: time_t,
191-
#[stable(feature = "raw_ext", since = "1.1.0")]
192-
pub st_mtime_nsec: c_long,
193-
#[stable(feature = "raw_ext", since = "1.1.0")]
194-
pub st_ctime: time_t,
195-
#[stable(feature = "raw_ext", since = "1.1.0")]
196-
pub st_ctime_nsec: c_long,
197-
#[stable(feature = "raw_ext", since = "1.1.0")]
198-
pub __unused: [c_int; 2],
199-
}
200-
}
201-
202-
#[cfg(target_arch = "x86_64")]
203-
mod arch {
204-
use super::{dev_t, mode_t};
205-
use os::raw::{c_long, c_int};
206-
use os::unix::raw::{gid_t, uid_t};
207-
208-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
209-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i64;
210-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
211-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
212-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
213-
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;
214-
215-
#[repr(C)]
216-
#[derive(Clone)]
217-
#[stable(feature = "raw_ext", since = "1.1.0")]
218-
pub struct stat {
219-
#[stable(feature = "raw_ext", since = "1.1.0")]
220-
pub st_dev: dev_t,
221-
#[stable(feature = "raw_ext", since = "1.1.0")]
222-
pub st_ino: ino_t,
223-
#[stable(feature = "raw_ext", since = "1.1.0")]
224-
pub st_nlink: nlink_t,
225-
#[stable(feature = "raw_ext", since = "1.1.0")]
226-
pub st_mode: mode_t,
227-
#[stable(feature = "raw_ext", since = "1.1.0")]
228-
pub st_uid: uid_t,
229-
#[stable(feature = "raw_ext", since = "1.1.0")]
230-
pub st_gid: gid_t,
231-
#[stable(feature = "raw_ext", since = "1.1.0")]
232-
pub __pad0: c_int,
233-
#[stable(feature = "raw_ext", since = "1.1.0")]
234-
pub st_rdev: dev_t,
235-
#[stable(feature = "raw_ext", since = "1.1.0")]
236-
pub st_size: off_t,
237-
#[stable(feature = "raw_ext", since = "1.1.0")]
238-
pub st_blksize: blksize_t,
239-
#[stable(feature = "raw_ext", since = "1.1.0")]
240-
pub st_blocks: blkcnt_t,
241-
#[stable(feature = "raw_ext", since = "1.1.0")]
242-
pub st_atime: time_t,
243-
#[stable(feature = "raw_ext", since = "1.1.0")]
244-
pub st_atime_nsec: c_long,
245-
#[stable(feature = "raw_ext", since = "1.1.0")]
246-
pub st_mtime: time_t,
247-
#[stable(feature = "raw_ext", since = "1.1.0")]
248-
pub st_mtime_nsec: c_long,
249-
#[stable(feature = "raw_ext", since = "1.1.0")]
250-
pub st_ctime: time_t,
251-
#[stable(feature = "raw_ext", since = "1.1.0")]
252-
pub st_ctime_nsec: c_long,
253-
#[stable(feature = "raw_ext", since = "1.1.0")]
254-
pub __unused: [c_long; 3],
255-
}
23+
#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u32;
24+
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i32;
25+
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i32;
26+
27+
#[repr(C)]
28+
#[derive(Copy, Clone)]
29+
#[stable(feature = "raw_ext", since = "1.1.0")]
30+
pub struct stat {
31+
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_dev: dev_t,
32+
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_ino: ino_t,
33+
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_mode: mode_t,
34+
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_nlink: nlink_t,
35+
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_uid: uid_t,
36+
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_gid: gid_t,
37+
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_rdev: dev_t,
38+
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_size: off_t,
39+
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_blksize: blksize_t,
40+
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_blocks: blkcnt_t,
41+
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_atime: time_t,
42+
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_atime_nsec: i64,
43+
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_mtime: time_t,
44+
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_mtime_nsec: i64,
45+
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_ctime: time_t,
46+
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_ctime_nsec: i64,
25647
}

src/libstd/rtdeps.rs

+8
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ extern {}
4444
#[link(name = "pthread")]
4545
extern {}
4646

47+
// For PNaCl targets, nacl_io is a Pepper wrapper for some IO functions
48+
// missing (ie always error) in Newlib.
49+
#[cfg(all(target_os = "nacl", not(test)))]
50+
#[link(name = "nacl_io", kind = "static")]
51+
#[link(name = "c++", kind = "static")] // for `nacl_io` and EH.
52+
#[link(name = "pthread", kind = "static")]
53+
extern {}
54+
4755
#[cfg(target_os = "macos")]
4856
#[link(name = "System")]
4957
extern {}

src/libstd/sys/common/backtrace.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![cfg_attr(target_os = "nacl", allow(dead_code))]
12+
1113
use env;
1214
use io::prelude::*;
1315
use io;

0 commit comments

Comments
 (0)