Skip to content

Commit 408db0d

Browse files
committed
Take sys/vxworks/{os,path,pipe} from sys/unix instead.
1 parent 71bb1dc commit 408db0d

File tree

5 files changed

+33
-446
lines changed

5 files changed

+33
-446
lines changed

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

+30-5
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ cfg_if::cfg_if! {
3737
}
3838

3939
extern "C" {
40-
#[cfg(not(target_os = "dragonfly"))]
40+
#[cfg(not(any(target_os = "dragonfly", target_os = "vxworks")))]
4141
#[cfg_attr(
4242
any(
4343
target_os = "linux",
@@ -67,18 +67,28 @@ extern "C" {
6767
}
6868

6969
/// Returns the platform-specific value of errno
70-
#[cfg(not(target_os = "dragonfly"))]
70+
#[cfg(not(any(target_os = "dragonfly", target_os = "vxworks")))]
7171
pub fn errno() -> i32 {
7272
unsafe { (*errno_location()) as i32 }
7373
}
7474

7575
/// Sets the platform-specific value of errno
76-
#[cfg(all(not(target_os = "linux"), not(target_os = "dragonfly")))] // needed for readdir and syscall!
76+
#[cfg(all(not(target_os = "linux"), not(target_os = "dragonfly"), not(target_os = "vxworks")))] // needed for readdir and syscall!
7777
#[allow(dead_code)] // but not all target cfgs actually end up using it
7878
pub fn set_errno(e: i32) {
7979
unsafe { *errno_location() = e as c_int }
8080
}
8181

82+
#[cfg(target_os = "vxworks")]
83+
pub fn errno() -> i32 {
84+
unsafe { libc::errnoGet() }
85+
}
86+
87+
#[cfg(target_os = "vxworks")]
88+
pub fn set_errno(e: i32) {
89+
unsafe { libc::errnoSet(e as c_int) };
90+
}
91+
8292
#[cfg(target_os = "dragonfly")]
8393
pub fn errno() -> i32 {
8494
extern "C" {
@@ -439,6 +449,19 @@ pub fn current_exe() -> io::Result<PathBuf> {
439449
Err(io::Error::new(ErrorKind::Other, "Not yet implemented!"))
440450
}
441451

452+
#[cfg(target_os = "vxworks")]
453+
pub fn current_exe() -> io::Result<PathBuf> {
454+
#[cfg(test)]
455+
use realstd::env;
456+
457+
#[cfg(not(test))]
458+
use crate::env;
459+
460+
let exe_path = env::args().next().unwrap();
461+
let path = path::Path::new(&exe_path);
462+
path.canonicalize()
463+
}
464+
442465
pub struct Env {
443466
iter: vec::IntoIter<(OsString, OsString)>,
444467
_dont_send_or_sync_me: PhantomData<*mut ()>,
@@ -568,7 +591,8 @@ pub fn home_dir() -> Option<PathBuf> {
568591
target_os = "android",
569592
target_os = "ios",
570593
target_os = "emscripten",
571-
target_os = "redox"
594+
target_os = "redox",
595+
target_os = "vxworks"
572596
))]
573597
unsafe fn fallback() -> Option<OsString> {
574598
None
@@ -577,7 +601,8 @@ pub fn home_dir() -> Option<PathBuf> {
577601
target_os = "android",
578602
target_os = "ios",
579603
target_os = "emscripten",
580-
target_os = "redox"
604+
target_os = "redox",
605+
target_os = "vxworks"
581606
)))]
582607
unsafe fn fallback() -> Option<OsString> {
583608
let amt = match libc::sysconf(libc::_SC_GETPW_R_SIZE_MAX) {

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

+3
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ pub mod memchr;
3434
pub mod mutex;
3535
#[path = "../unix/net.rs"]
3636
pub mod net;
37+
#[path = "../unix/os.rs"]
3738
pub mod os;
39+
#[path = "../unix/path.rs"]
3840
pub mod path;
41+
#[path = "../unix/pipe.rs"]
3942
pub mod pipe;
4043
pub mod process;
4144
pub mod rand;

0 commit comments

Comments
 (0)