Skip to content

Commit

Permalink
Fix vxworks compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
CDirkx committed Apr 19, 2021
1 parent 1212040 commit 9bd9cbb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
11 changes: 3 additions & 8 deletions library/std/src/sys/unix/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ pub fn errno() -> i32 {
unsafe { libc::errnoGet() }
}

#[cfg(target_os = "vxworks")]
pub fn set_errno(e: i32) {
unsafe { libc::errnoSet(e as c_int) };
}

#[cfg(target_os = "dragonfly")]
pub fn errno() -> i32 {
extern "C" {
Expand Down Expand Up @@ -642,7 +637,7 @@ pub fn getppid() -> u32 {
unsafe { libc::getppid() as u32 }
}

#[cfg(target_env = "gnu")]
#[cfg(all(target_env = "gnu", not(target_os = "vxworks")))]
pub fn glibc_version() -> Option<(usize, usize)> {
if let Some(Ok(version_str)) = glibc_version_cstr().map(CStr::to_str) {
parse_glibc_version(version_str)
Expand All @@ -651,7 +646,7 @@ pub fn glibc_version() -> Option<(usize, usize)> {
}
}

#[cfg(target_env = "gnu")]
#[cfg(all(target_env = "gnu", not(target_os = "vxworks")))]
fn glibc_version_cstr() -> Option<&'static CStr> {
weak! {
fn gnu_get_libc_version() -> *const libc::c_char
Expand All @@ -665,7 +660,7 @@ fn glibc_version_cstr() -> Option<&'static CStr> {

// Returns Some((major, minor)) if the string is a valid "x.y" version,
// ignoring any extra dot-separated parts. Otherwise return None.
#[cfg(target_env = "gnu")]
#[cfg(all(target_env = "gnu", not(target_os = "vxworks")))]
fn parse_glibc_version(version: &str) -> Option<(usize, usize)> {
let mut parsed_ints = version.split('.').map(str::parse::<usize>).fuse();
match (parsed_ints.next(), parsed_ints.next()) {
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/unix/process/process_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ impl Command {
pub fn get_groups(&self) -> Option<&[gid_t]> {
self.groups.as_deref()
}

#[allow(dead_code)]
pub fn get_closures(&mut self) -> &mut Vec<Box<dyn FnMut() -> io::Result<()> + Send + Sync>> {
&mut self.closures
}
Expand Down
20 changes: 19 additions & 1 deletion library/std/src/sys/unix/process/process_vxworks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl Command {
needs_stdin: bool,
) -> io::Result<(Process, StdioPipes)> {
use crate::sys::cvt_r;
const CLOEXEC_MSG_FOOTER: &'static [u8] = b"NOEX";
// const CLOEXEC_MSG_FOOTER: &'static [u8] = b"NOEX";
let envp = self.capture_env();

if self.saw_nul() {
Expand Down Expand Up @@ -196,6 +196,24 @@ impl ExitStatus {
pub fn signal(&self) -> Option<i32> {
if !self.exited() { Some(libc::WTERMSIG(self.0)) } else { None }
}

pub fn core_dumped(&self) -> bool {
// This method is not yet properly implemented on VxWorks
false
}

pub fn stopped_signal(&self) -> Option<i32> {
if libc::WIFSTOPPED(self.0) { Some(libc::WSTOPSIG(self.0)) } else { None }
}

pub fn continued(&self) -> bool {
// This method is not yet properly implemented on VxWorks
false
}

pub fn into_raw(&self) -> c_int {
self.0
}
}

/// Converts a raw `c_int` to a type-safe `ExitStatus` by wrapping it without copying.
Expand Down

0 comments on commit 9bd9cbb

Please sign in to comment.