Skip to content

Commit 1212040

Browse files
committed
Move sys::vxworks code to sys::unix
1 parent 6265286 commit 1212040

File tree

13 files changed

+64
-213
lines changed

13 files changed

+64
-213
lines changed

library/std/src/sys/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@
2525
mod common;
2626

2727
cfg_if::cfg_if! {
28-
if #[cfg(target_os = "vxworks")] {
29-
mod vxworks;
30-
pub use self::vxworks::*;
31-
} else if #[cfg(unix)] {
28+
if #[cfg(unix)] {
3229
mod unix;
3330
pub use self::unix::*;
3431
} else if #[cfg(windows)] {

library/std/src/sys/unix/env.rs

+11
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,14 @@ pub mod os {
173173
pub const EXE_SUFFIX: &str = "";
174174
pub const EXE_EXTENSION: &str = "";
175175
}
176+
177+
#[cfg(target_os = "vxworks")]
178+
pub mod os {
179+
pub const FAMILY: &str = "unix";
180+
pub const OS: &str = "vxworks";
181+
pub const DLL_PREFIX: &str = "lib";
182+
pub const DLL_SUFFIX: &str = ".so";
183+
pub const DLL_EXTENSION: &str = "so";
184+
pub const EXE_SUFFIX: &str = "";
185+
pub const EXE_EXTENSION: &str = "";
186+
}

library/std/src/sys/unix/ext/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ cfg_if::cfg_if! {
6262
use crate::os::redox as platform;
6363
#[cfg(target_os = "solaris")]
6464
use crate::os::solaris as platform;
65+
#[cfg(target_os = "vxworks")]
66+
use crate::os::vxworks as platform;
6567
}
6668
}
6769

library/std/src/sys/unix/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ pub fn init() {
7171
} else if #[cfg(not(any(
7272
target_os = "emscripten",
7373
target_os = "fuchsia",
74+
target_os = "vxworks",
7475
// The poll on Darwin doesn't set POLLNVAL for closed fds.
7576
target_os = "macos",
7677
target_os = "ios",

library/std/src/sys/unix/process/mod.rs

+14-8
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@ pub use crate::ffi::OsString as EnvKey;
44
pub use crate::sys_common::process::CommandEnvs;
55

66
mod process_common;
7-
#[cfg(not(target_os = "fuchsia"))]
8-
#[path = "process_unix.rs"]
9-
mod process_inner;
10-
#[cfg(target_os = "fuchsia")]
11-
#[path = "process_fuchsia.rs"]
12-
mod process_inner;
13-
#[cfg(target_os = "fuchsia")]
14-
mod zircon;
7+
8+
cfg_if::cfg_if! {
9+
if #[cfg(target_os = "fuchsia")] {
10+
#[path = "process_fuchsia.rs"]
11+
mod process_inner;
12+
mod zircon;
13+
} else if #[cfg(target_os = "vxworks")] {
14+
#[path = "process_vxworks.rs"]
15+
mod process_inner;
16+
} else {
17+
#[path = "process_unix.rs"]
18+
mod process_inner;
19+
}
20+
}

library/std/src/sys/vxworks/process/process_vxworks.rs renamed to library/std/src/sys/unix/process/process_vxworks.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl Command {
6868
let stack_size = thread::min_stack();
6969

7070
// ensure that access to the environment is synchronized
71-
let _lock = sys::os::env_lock();
71+
let _lock = sys::os::env_read_lock();
7272

7373
let ret = libc::rtpSpawn(
7474
self.get_program_cstr().as_ptr(),

library/std/src/sys/unix/rand.rs

+28-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ pub fn hashmap_random_keys() -> (u64, u64) {
1818
not(target_os = "freebsd"),
1919
not(target_os = "netbsd"),
2020
not(target_os = "fuchsia"),
21-
not(target_os = "redox")
21+
not(target_os = "redox"),
22+
not(target_os = "vxworks")
2223
))]
2324
mod imp {
2425
use crate::fs::File;
@@ -237,3 +238,29 @@ mod imp {
237238
file.read_exact(v).expect("failed to read rand:")
238239
}
239240
}
241+
242+
#[cfg(target_os = "vxworks")]
243+
mod imp {
244+
use crate::io;
245+
use core::sync::atomic::{AtomicBool, Ordering::Relaxed};
246+
247+
pub fn fill_bytes(v: &mut [u8]) {
248+
static RNG_INIT: AtomicBool = AtomicBool::new(false);
249+
while !RNG_INIT.load(Relaxed) {
250+
let ret = unsafe { libc::randSecure() };
251+
if ret < 0 {
252+
panic!("couldn't generate random bytes: {}", io::Error::last_os_error());
253+
} else if ret > 0 {
254+
RNG_INIT.store(true, Relaxed);
255+
break;
256+
}
257+
unsafe { libc::usleep(10) };
258+
}
259+
let ret = unsafe {
260+
libc::randABytes(v.as_mut_ptr() as *mut libc::c_uchar, v.len() as libc::c_int)
261+
};
262+
if ret < 0 {
263+
panic!("couldn't generate random bytes: {}", io::Error::last_os_error());
264+
}
265+
}
266+
}

library/std/src/sys/unix/thread_local_dtor.rs

+6
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,9 @@ pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) {
9292
}
9393
}
9494
}
95+
96+
#[cfg(target_os = "vxworks")]
97+
pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) {
98+
use crate::sys_common::thread_local_dtor::register_dtor_fallback;
99+
register_dtor_fallback(t, dtor);
100+
}

library/std/src/sys/vxworks/env.rs

-9
This file was deleted.

library/std/src/sys/vxworks/mod.rs

-138
This file was deleted.

library/std/src/sys/vxworks/process/mod.rs

-9
This file was deleted.

library/std/src/sys/vxworks/rand.rs

-36
This file was deleted.

library/std/src/sys/vxworks/thread_local_dtor.rs

-7
This file was deleted.

0 commit comments

Comments
 (0)