From 4dd4da97175b1c6cf15fc9505ec8f8afdaf71a24 Mon Sep 17 00:00:00 2001 From: Baoshan Pang Date: Fri, 30 Aug 2019 13:44:38 -0700 Subject: [PATCH 1/2] remove directory libstd/sys/vxworks/backtrace which is not used any more --- src/libstd/sys/vxworks/backtrace/mod.rs | 110 ------------------ .../sys/vxworks/backtrace/printing/dladdr.rs | 35 ------ .../sys/vxworks/backtrace/printing/mod.rs | 33 ------ .../vxworks/backtrace/tracing/backtrace_fn.rs | 39 ------- .../sys/vxworks/backtrace/tracing/gcc_s.rs | 99 ---------------- .../sys/vxworks/backtrace/tracing/mod.rs | 8 -- 6 files changed, 324 deletions(-) delete mode 100644 src/libstd/sys/vxworks/backtrace/mod.rs delete mode 100644 src/libstd/sys/vxworks/backtrace/printing/dladdr.rs delete mode 100644 src/libstd/sys/vxworks/backtrace/printing/mod.rs delete mode 100644 src/libstd/sys/vxworks/backtrace/tracing/backtrace_fn.rs delete mode 100644 src/libstd/sys/vxworks/backtrace/tracing/gcc_s.rs delete mode 100644 src/libstd/sys/vxworks/backtrace/tracing/mod.rs diff --git a/src/libstd/sys/vxworks/backtrace/mod.rs b/src/libstd/sys/vxworks/backtrace/mod.rs deleted file mode 100644 index 0887e5a4df937..0000000000000 --- a/src/libstd/sys/vxworks/backtrace/mod.rs +++ /dev/null @@ -1,110 +0,0 @@ -/// Backtrace support built on libgcc with some extra OS-specific support -/// -/// Some methods of getting a backtrace: -/// -/// * The backtrace() functions on unix. It turns out this doesn't work very -/// well for green threads on macOS, and the address to symbol portion of it -/// suffers problems that are described below. -/// -/// * Using libunwind. This is more difficult than it sounds because libunwind -/// isn't installed everywhere by default. It's also a bit of a hefty library, -/// so possibly not the best option. When testing, libunwind was excellent at -/// getting both accurate backtraces and accurate symbols across platforms. -/// This route was not chosen in favor of the next option, however. -/// -/// * We're already using libgcc_s for exceptions in rust (triggering thread -/// unwinding and running destructors on the stack), and it turns out that it -/// conveniently comes with a function that also gives us a backtrace. All of -/// these functions look like _Unwind_*, but it's not quite the full -/// repertoire of the libunwind API. Due to it already being in use, this was -/// the chosen route of getting a backtrace. -/// -/// After choosing libgcc_s for backtraces, the sad part is that it will only -/// give us a stack trace of instruction pointers. Thankfully these instruction -/// pointers are accurate (they work for green and native threads), but it's -/// then up to us again to figure out how to translate these addresses to -/// symbols. As with before, we have a few options. Before, that, a little bit -/// of an interlude about symbols. This is my very limited knowledge about -/// symbol tables, and this information is likely slightly wrong, but the -/// general idea should be correct. -/// -/// When talking about symbols, it's helpful to know a few things about where -/// symbols are located. Some symbols are located in the dynamic symbol table -/// of the executable which in theory means that they're available for dynamic -/// linking and lookup. Other symbols end up only in the local symbol table of -/// the file. This loosely corresponds to pub and priv functions in Rust. -/// -/// Armed with this knowledge, we know that our solution for address to symbol -/// translation will need to consult both the local and dynamic symbol tables. -/// With that in mind, here's our options of translating an address to -/// a symbol. -/// -/// * Use dladdr(). The original backtrace()-based idea actually uses dladdr() -/// behind the scenes to translate, and this is why backtrace() was not used. -/// Conveniently, this method works fantastically on macOS. It appears dladdr() -/// uses magic to consult the local symbol table, or we're putting everything -/// in the dynamic symbol table anyway. Regardless, for macOS, this is the -/// method used for translation. It's provided by the system and easy to do.o -/// -/// Sadly, all other systems have a dladdr() implementation that does not -/// consult the local symbol table. This means that most functions are blank -/// because they don't have symbols. This means that we need another solution. -/// -/// * Use unw_get_proc_name(). This is part of the libunwind api (not the -/// libgcc_s version of the libunwind api), but involves taking a dependency -/// to libunwind. We may pursue this route in the future if we bundle -/// libunwind, but libunwind was unwieldy enough that it was not chosen at -/// this time to provide this functionality. -/// -/// * Shell out to a utility like `readelf`. Crazy though it may sound, it's a -/// semi-reasonable solution. The stdlib already knows how to spawn processes, -/// so in theory it could invoke readelf, parse the output, and consult the -/// local/dynamic symbol tables from there. This ended up not getting chosen -/// due to the craziness of the idea plus the advent of the next option. -/// -/// * Use `libbacktrace`. It turns out that this is a small library bundled in -/// the gcc repository which provides backtrace and symbol translation -/// functionality. All we really need from it is the backtrace functionality, -/// and we only really need this on everything that's not macOS, so this is the -/// chosen route for now. -/// -/// In summary, the current situation uses libgcc_s to get a trace of stack -/// pointers, and we use dladdr() or libbacktrace to translate these addresses -/// to symbols. This is a bit of a hokey implementation as-is, but it works for -/// all unix platforms we support right now, so it at least gets the job done. - -pub use self::tracing::unwind_backtrace; -pub use self::printing::{foreach_symbol_fileline, resolve_symname}; - -// tracing impls: -mod tracing; -// symbol resolvers: -mod printing; - -#[cfg(not(target_os = "emscripten"))] -pub mod gnu { - use crate::io; - use crate::fs; - - use libc::c_char; - - #[cfg(not(any(target_os = "macos", target_os = "ios")))] - pub fn get_executable_filename() -> io::Result<(Vec, fs::File)> { - Err(io::Error::new(io::ErrorKind::Other, "Not implemented")) - } - - #[cfg(any(target_os = "macos", target_os = "ios"))] - pub fn get_executable_filename() -> io::Result<(Vec, fs::File)> { - use crate::env; - use crate::os::unix::ffi::OsStrExt; - - let filename = env::current_exe()?; - let file = fs::File::open(&filename)?; - let mut filename_cstr: Vec<_> = filename.as_os_str().as_bytes().iter() - .map(|&x| x as c_char).collect(); - filename_cstr.push(0); // Null terminate - Ok((filename_cstr, file)) - } -} - -pub struct BacktraceContext; diff --git a/src/libstd/sys/vxworks/backtrace/printing/dladdr.rs b/src/libstd/sys/vxworks/backtrace/printing/dladdr.rs deleted file mode 100644 index 202164dd3c4d7..0000000000000 --- a/src/libstd/sys/vxworks/backtrace/printing/dladdr.rs +++ /dev/null @@ -1,35 +0,0 @@ -use crate::io; -use crate::intrinsics; -use crate::ffi::CStr; -use crate::sys::backtrace::BacktraceContext; -use crate::sys_common::backtrace::Frame; - -pub fn resolve_symname(frame: Frame, - callback: F, - _: &BacktraceContext) -> io::Result<()> - where F: FnOnce(Option<&str>) -> io::Result<()> -{ - unsafe { - let mut info: Dl_info = intrinsics::init(); - let symname = if dladdr(frame.exact_position as *mut _, &mut info) == 0 || - info.dli_sname.is_null() { - None - } else { - CStr::from_ptr(info.dli_sname).to_str().ok() - }; - callback(symname) - } -} - -#[repr(C)] -struct Dl_info { - dli_fname: *const libc::c_char, - dli_fbase: *mut libc::c_void, - dli_sname: *const libc::c_char, - dli_saddr: *mut libc::c_void, -} - -extern { - #[ link_name = "_rtld_dladdr" ] - fn dladdr(addr: *const libc::c_void, info: *mut Dl_info) -> libc::c_int; -} diff --git a/src/libstd/sys/vxworks/backtrace/printing/mod.rs b/src/libstd/sys/vxworks/backtrace/printing/mod.rs deleted file mode 100644 index d090caede437a..0000000000000 --- a/src/libstd/sys/vxworks/backtrace/printing/mod.rs +++ /dev/null @@ -1,33 +0,0 @@ -mod dladdr; - -use crate::sys::backtrace::BacktraceContext; -use crate::sys_common::backtrace::Frame; -use crate::io; - -#[cfg(target_os = "emscripten")] -pub use self::dladdr::resolve_symname; - -#[cfg(target_os = "emscripten")] -pub fn foreach_symbol_fileline(_: Frame, _: F, _: &BacktraceContext) -> io::Result -where - F: FnMut(&[u8], u32) -> io::Result<()> -{ - Ok(false) -} - -#[cfg(not(target_os = "emscripten"))] -pub use crate::sys_common::gnu::libbacktrace::foreach_symbol_fileline; - -#[cfg(not(target_os = "emscripten"))] -pub fn resolve_symname(frame: Frame, callback: F, bc: &BacktraceContext) -> io::Result<()> -where - F: FnOnce(Option<&str>) -> io::Result<()> -{ - crate::sys_common::gnu::libbacktrace::resolve_symname(frame, |symname| { - if symname.is_some() { - callback(symname) - } else { - dladdr::resolve_symname(frame, callback, bc) - } - }, bc) -} diff --git a/src/libstd/sys/vxworks/backtrace/tracing/backtrace_fn.rs b/src/libstd/sys/vxworks/backtrace/tracing/backtrace_fn.rs deleted file mode 100644 index a628d107ad6fb..0000000000000 --- a/src/libstd/sys/vxworks/backtrace/tracing/backtrace_fn.rs +++ /dev/null @@ -1,39 +0,0 @@ -/// As always - iOS on arm uses SjLj exceptions and -/// _Unwind_Backtrace is even not available there. Still, -/// backtraces could be extracted using a backtrace function, -/// which thanks god is public -/// -/// As mentioned in a huge comment block in `super::super`, backtrace -/// doesn't play well with green threads, so while it is extremely nice and -/// simple to use it should be used only on iOS devices as the only viable -/// option. - -use crate::io; -use crate::ptr; -use crate::sys::backtrace::BacktraceContext; -use crate::sys_common::backtrace::Frame; - -#[inline(never)] // if we know this is a function call, we can skip it when - // tracing -pub fn unwind_backtrace(frames: &mut [Frame]) - -> io::Result<(usize, BacktraceContext)> -{ - const FRAME_LEN: usize = 100; - assert!(FRAME_LEN >= frames.len()); - let mut raw_frames = [ptr::null_mut(); FRAME_LEN]; - let nb_frames = unsafe { - backtrace(raw_frames.as_mut_ptr(), raw_frames.len() as libc::c_int) - } as usize; - for (from, to) in raw_frames.iter().zip(frames.iter_mut()).take(nb_frames) { - *to = Frame { - exact_position: *from as *mut u8, - symbol_addr: *from as *mut u8, - inline_context: 0, - }; - } - Ok((nb_frames as usize, BacktraceContext)) -} - -extern { - fn backtrace(buf: *mut *mut libc::c_void, sz: libc::c_int) -> libc::c_int; -} diff --git a/src/libstd/sys/vxworks/backtrace/tracing/gcc_s.rs b/src/libstd/sys/vxworks/backtrace/tracing/gcc_s.rs deleted file mode 100644 index e6379132bafbe..0000000000000 --- a/src/libstd/sys/vxworks/backtrace/tracing/gcc_s.rs +++ /dev/null @@ -1,99 +0,0 @@ -use crate::error::Error; -use crate::fmt; -use crate::io; -use crate::sys::backtrace::BacktraceContext; -use crate::sys_common::backtrace::Frame; - -use unwind as uw; - -struct Context<'a> { - idx: usize, - frames: &'a mut [Frame], -} - -#[derive(Debug)] -struct UnwindError(uw::_Unwind_Reason_Code); - -impl Error for UnwindError { - fn description(&self) -> &'static str { - "unexpected return value while unwinding" - } -} - -impl fmt::Display for UnwindError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}: {:?}", self.description(), self.0) - } -} - -#[inline(never)] // if we know this is a function call, we can skip it when - // tracing -pub fn unwind_backtrace(frames: &mut [Frame]) - -> io::Result<(usize, BacktraceContext)> -{ - let mut cx = Context { - idx: 0, - frames, - }; - let result_unwind = unsafe { - uw::_Unwind_Backtrace(trace_fn, - &mut cx as *mut Context<'_> - as *mut libc::c_void) - }; - // See libunwind:src/unwind/Backtrace.c for the return values. - // No, there is no doc. - match result_unwind { - // These return codes seem to be benign and need to be ignored for backtraces - // to show up properly on all tested platforms. - uw::_URC_END_OF_STACK | uw::_URC_FATAL_PHASE1_ERROR | uw::_URC_FAILURE => { - Ok((cx.idx, BacktraceContext)) - } - _ => { - Err(io::Error::new(io::ErrorKind::Other, - UnwindError(result_unwind))) - } - } -} - -extern fn trace_fn(ctx: *mut uw::_Unwind_Context, - arg: *mut libc::c_void) -> uw::_Unwind_Reason_Code { - let cx = unsafe { &mut *(arg as *mut Context<'_>) }; - if cx.idx >= cx.frames.len() { - return uw::_URC_NORMAL_STOP; - } - - let mut ip_before_insn = 0; - let mut ip = unsafe { - uw::_Unwind_GetIPInfo(ctx, &mut ip_before_insn) as *mut libc::c_void - }; - if !ip.is_null() && ip_before_insn == 0 { - // this is a non-signaling frame, so `ip` refers to the address - // after the calling instruction. account for that. - ip = (ip as usize - 1) as *mut _; - } - - // dladdr() on osx gets whiny when we use FindEnclosingFunction, and - // it appears to work fine without it, so we only use - // FindEnclosingFunction on non-osx platforms. In doing so, we get a - // slightly more accurate stack trace in the process. - // - // This is often because panic involves the last instruction of a - // function being "call std::rt::begin_unwind", with no ret - // instructions after it. This means that the return instruction - // pointer points *outside* of the calling function, and by - // unwinding it we go back to the original function. - let symaddr = if cfg!(target_os = "macos") || cfg!(target_os = "ios") { - ip - } else { - unsafe { uw::_Unwind_FindEnclosingFunction(ip) } - }; - - cx.frames[cx.idx] = Frame { - symbol_addr: symaddr as *mut u8, - exact_position: ip as *mut u8, - inline_context: 0, - }; - cx.idx += 1; - - uw::_URC_NO_REASON -} diff --git a/src/libstd/sys/vxworks/backtrace/tracing/mod.rs b/src/libstd/sys/vxworks/backtrace/tracing/mod.rs deleted file mode 100644 index 11863e6454525..0000000000000 --- a/src/libstd/sys/vxworks/backtrace/tracing/mod.rs +++ /dev/null @@ -1,8 +0,0 @@ -pub use self::imp::*; - -#[cfg(not(all(target_os = "ios", target_arch = "arm")))] -#[path = "gcc_s.rs"] -mod imp; -#[cfg(all(target_os = "ios", target_arch = "arm"))] -#[path = "backtrace_fn.rs"] -mod imp; From b548814a8b01ee155ceb2946fc92a47dcbe74197 Mon Sep 17 00:00:00 2001 From: Baoshan Pang Date: Mon, 23 Sep 2019 15:37:18 -0700 Subject: [PATCH 2/2] remove rtp.rs, and move rtpSpawn and RTP_ID_ERROR to libc --- src/libstd/sys/vxworks/process/mod.rs | 1 - .../sys/vxworks/process/process_vxworks.rs | 5 +- src/libstd/sys/vxworks/process/rtp.rs | 298 ------------------ 3 files changed, 2 insertions(+), 302 deletions(-) delete mode 100644 src/libstd/sys/vxworks/process/rtp.rs diff --git a/src/libstd/sys/vxworks/process/mod.rs b/src/libstd/sys/vxworks/process/mod.rs index 1fc88fbde742f..3ecbe4e3b28ba 100644 --- a/src/libstd/sys/vxworks/process/mod.rs +++ b/src/libstd/sys/vxworks/process/mod.rs @@ -5,4 +5,3 @@ pub use crate::ffi::OsString as EnvKey; mod process_common; #[path = "process_vxworks.rs"] mod process_inner; -mod rtp; diff --git a/src/libstd/sys/vxworks/process/process_vxworks.rs b/src/libstd/sys/vxworks/process/process_vxworks.rs index 8780df17a1c7e..beb20aa48169a 100644 --- a/src/libstd/sys/vxworks/process/process_vxworks.rs +++ b/src/libstd/sys/vxworks/process/process_vxworks.rs @@ -3,7 +3,6 @@ use libc::{self, c_int, c_char}; use libc::{RTP_ID}; use crate::sys; use crate::sys::cvt; -use crate::sys::process::rtp; use crate::sys::process::process_common::*; use crate::sys_common::thread; @@ -53,7 +52,7 @@ impl Command { t!(cvt(libc::chdir(cwd.as_ptr()))); } - let ret = rtp::rtpSpawn( + let ret = libc::rtpSpawn( self.get_argv()[0], // executing program self.get_argv().as_ptr() as *const _, // argv *sys::os::environ() as *const *const c_char, @@ -78,7 +77,7 @@ impl Command { libc::close(orig_stderr); } - if ret != rtp::RTP_ID_ERROR { + if ret != libc::RTP_ID_ERROR { p.pid = ret; Ok((p, ours)) } else { diff --git a/src/libstd/sys/vxworks/process/rtp.rs b/src/libstd/sys/vxworks/process/rtp.rs deleted file mode 100644 index 3e6e0017abcb5..0000000000000 --- a/src/libstd/sys/vxworks/process/rtp.rs +++ /dev/null @@ -1,298 +0,0 @@ -#![allow(non_camel_case_types, unused)] - -use libc::{self, c_int, size_t, c_char, BOOL, RTP_DESC, RTP_ID, TASK_ID}; - - -// Copied directly from rtpLibCommon.h, rtpLib.h, signal.h and taskLibCommon.h (for task options) - -// **** definitions for rtpLibCommon.h **** - -pub const RTP_GLOBAL_SYMBOLS : c_int = 0x01; // register global symbols for RTP -pub const RTP_LOCAL_SYMBOLS : c_int = 0x02; // idem for local symbols -pub const RTP_ALL_SYMBOLS : c_int = (RTP_GLOBAL_SYMBOLS | RTP_LOCAL_SYMBOLS); -pub const RTP_DEBUG : c_int = 0x10; // set RTP in debug mode when created -pub const RTP_BUFFER_VAL_OFF : c_int = 0x20; // disable buffer validation for all - // system calls issued from the RTP -pub const RTP_LOADED_WAIT : c_int = 0x40; // Wait until the RTP is loaded -pub const RTP_CPU_AFFINITY_NONE : c_int = 0x80; // Remove any CPU affinity (SMP) - -// Error Status codes - -pub const M_rtpLib : c_int = 178 << 16; - -pub const S_rtpLib_INVALID_FILE : c_int = (M_rtpLib | 1); -pub const S_rtpLib_INVALID_OPTION : c_int = (M_rtpLib | 2); -pub const S_rtpLib_ACCESS_DENIED : c_int = (M_rtpLib | 3); -pub const S_rtpLib_INVALID_RTP_ID : c_int = (M_rtpLib | 4); -pub const S_rtpLib_NO_SYMBOL_TABLE : c_int = (M_rtpLib | 5); -pub const S_rtpLib_INVALID_SEGMENT_START_ADDRESS : c_int = (M_rtpLib | 6); -pub const S_rtpLib_INVALID_SYMBOL_REGISTR_POLICY : c_int = (M_rtpLib | 7); -pub const S_rtpLib_INSTANTIATE_FAILED : c_int = (M_rtpLib | 8); -pub const S_rtpLib_INVALID_TASK_OPTION : c_int = (M_rtpLib | 9); -pub const S_rtpLib_RTP_NAME_LENGTH_EXCEEDED : c_int = (M_rtpLib | 10); // rtpInfoGet - -pub const VX_RTP_NAME_LENGTH : c_int = 255; // max name length for diplay - - -// The 'status' field (32 bit integer) of a RTP holds the RTP state and status. -// -// NOTE: RTP_STATE_GET() : read the RTP state(s) -// RTP_STATE_PUT() : write the RTP state(s) -// RTP_STATE_SET() : set a RTP state -// RTP_STATE_UNSET() : unset a RTP state -// -// RTP_STATUS_GET() : read the RTP status -// RTP_STATUS_PUT() : write the RTP status -// RTP_STATUS_SET() : set a RTP status -// RTP_STATUS_UNSET() : unset a RTP status -// -// The PUT/SET/UNSET macros are available only in the kernel headers. - - -// RTP states - -pub const RTP_STATE_CREATE : c_int = 0x0001; // RrtpStructTP is under construction -pub const RTP_STATE_NORMAL : c_int = 0x0002; // RrtpStructTP is ready -pub const RTP_STATE_DELETE : c_int = 0x0004; // RrtpStructTP is being deleted - -pub const RTP_STATUS_STOP : c_int = 0x0100; // RTP hrtpStructas recieved stopped signal -pub const RTP_STATUS_ELECTED_DELETER : c_int = 0x0200; // RTP drtpStructelete has started - -pub const RTP_STATE_MASK : c_int = (RTP_STATE_CREATE | RTP_STATE_NORMAL | - RTP_STATE_DELETE); -pub const RTP_STATUS_MASK : c_int = (RTP_STATUS_STOP | RTP_STATUS_ELECTED_DELETER); - -pub fn RTP_STATE_GET (value : c_int) -> c_int { - value & RTP_STATE_MASK -} -pub fn RTP_STATUS_GET (value : c_int) -> c_int { - value & RTP_STATUS_MASK -} - -// Indicates that the RTP_ID returned is not valid. - -// RTP_ID_ERROR is supposed to be set to -1, but you can't set -// an unsigned value to a negative without casting, and you -// can't cast unless the size of the integer types are the same, -// but the size of RTP_ID may differ between kernel and user space. -// Bitwise or-ing min and max should get the same result. -pub const RTP_ID_ERROR : RTP_ID = RTP_ID::min_value() | RTP_ID::max_value(); - -// IS_RTP_ C macros - -pub fn IS_RTP_STATE_NORMAL (value : c_int) -> bool { - (RTP_STATE_GET(value) & RTP_STATE_NORMAL) == RTP_STATE_NORMAL -} -pub fn IS_RTP_STATE_CREATE (value : c_int) -> bool { - (RTP_STATE_GET(value) & RTP_STATE_CREATE) == RTP_STATE_CREATE -} -pub fn IS_RTP_STATE_DELETE (value : c_int) -> bool { - (RTP_STATE_GET(value) & RTP_STATE_DELETE) == RTP_STATE_DELETE -} -pub fn IS_RTP_STATUS_STOP (value : c_int) -> bool { - (RTP_STATUS_GET(value) & RTP_STATUS_STOP ) == RTP_STATUS_STOP -} -pub fn IS_RTP_STATUS_ELECTED_DELETER (value : c_int) -> bool { - (RTP_STATUS_GET(value) & RTP_STATUS_ELECTED_DELETER) == RTP_STATUS_ELECTED_DELETER -} - -// **** end of definitions for rtpLibCommon.h **** - - - - -// **** definitions for rtpLib.h **** - -pub fn rtpExit(exitCode : c_int) -> ! { - unsafe{ libc::exit (exitCode) } -} - -/* rtpLib.h in the kernel -pub const RTP_DEL_VIA_TASK_DELETE : c_int = 0x1; // rtpDelete() via taskDestroy() -pub const RTP_DEL_FORCE : c_int = 0x2; // Forceful rtpDelete() -pub const RTP_ID_ANY : RTP_ID = 0; // used for when a kernel task - // wants to wait for the next - // RTP to finish - - -// Function pointers - -pub type RTP_PRE_CREATE_HOOK = size_t; -pub type RTP_POST_CREATE_HOOK = size_t; -pub type RTP_INIT_COMPLETE_HOOK = size_t; -pub type RTP_DELETE_HOOK = size_t; -*/ - -// **** end of definitions for rtpLib.h **** - - - - - -// **** definitions for signal.h **** -pub fn rtpKill(rtpId : RTP_ID, signo : c_int) -> c_int { - unsafe{ libc::kill(rtpId as c_int, signo) } -} - -pub fn rtpSigqueue(rtpId : RTP_ID, signo : c_int, value : size_t) -> c_int { - unsafe{ libc::sigqueue(rtpId as c_int, signo, value) } -} - -pub fn _rtpSigqueue(rtpId : RTP_ID, signo : c_int, value : *mut size_t, code : c_int) -> c_int { - unsafe{ libc::_sigqueue(rtpId, signo, value, code) } -} - -pub fn taskRaise(signo : c_int) -> c_int { - unsafe{ libc::taskKill(libc::taskIdSelf(), signo) } -} -pub fn rtpRaise(signo : c_int) -> c_int { - unsafe{ libc::raise(signo) } -} - -// **** end of definitions for signal.h **** - - - -// **** definitions for taskLibCommon.h **** -pub const VX_PRIVATE_ENV : c_int = 0x0080; // 1 = private environment variables -pub const VX_NO_STACK_FILL : c_int = 0x0100; // 1 = avoid stack fill of 0xee -pub const VX_PRIVATE_UMASK : c_int = 0x0400; // 1 = private file creation mode mask -pub const VX_TASK_NOACTIVATE : c_int = 0x2000; // taskOpen() does not taskActivate() -pub const VX_NO_STACK_PROTECT : c_int = 0x4000; // no over/underflow stack protection, - // stack space remains executable - -// define for all valid user task options - -pub const VX_USR_TASK_OPTIONS_BASE: c_int = (VX_PRIVATE_ENV | - VX_NO_STACK_FILL | - VX_TASK_NOACTIVATE | - VX_NO_STACK_PROTECT | - VX_PRIVATE_UMASK); - -// **** end of definitions for taskLibCommon.h **** - - - -extern "C" { -// functions in rtpLibCommon.h - -// forward declarations - pub fn rtpSpawn ( - pubrtpFileName : *const c_char, - argv : *const *const c_char, - envp : *const *const c_char, - priority : c_int, - uStackSize : size_t, - options : c_int, - taskOptions : c_int, - ) -> RTP_ID; - - pub fn rtpInfoGet ( - rtpId : RTP_ID, - rtpStruct : *mut RTP_DESC, - ) -> c_int; - -/* functions in rtpLib.h for kernel - - - // function declarations - - pub fn rtpDelete ( - id : RTP_ID, - options : c_int, - status : c_int, - ) -> c_int; - - pub fn rtpDeleteForce ( - rtpId : RTP_ID - ) -> c_int; - - pub fn rtpShow ( - rtpNameOrId : *mut c_char, - level : c_int, - ) -> BOOL; - - // RTP signals are always present when RTPs are included. The public RTP - // signal APIs are declared here. - - - pub fn rtpKill ( - rtpId : RTP_ID, - signo : c_int, - ) -> c_int; - - pub fn rtpSigqueue ( - rtpId : RTP_ID, - signo : c_int, - value : size_t, // Actual type is const union sigval value, - // which is a union of int and void * - ) -> c_int; - - pub fn rtpTaskKill ( - tid : TASK_ID, - signo : c_int, - ) -> c_int; - - pub fn rtpTaskSigqueue ( - tid : TASK_ID, - signo : c_int, - value : const size_t, // Actual type is const union sigval, - // which is a union of int and void * - ) -> c_int; - - pub fn rtpWait ( - rtpWaitId : RTP_ID, - timeout : libc::alloc_jemalloc_Vx_ticks_t, - pRtpId : *mut RTP_ID, - pStatus : *mut c_int, - ) -> c_int; - - // Other public functions - - - pub fn rtpPreCreateHookAdd ( - hook : RTP_PRE_CREATE_HOOK, - addToHead : BOOL, - ) -> c_int; - - pub fn rtpPreCreateHookDelete ( - hook : RTP_POST_CREATE_HOOK, - ) -> c_int; - - pub fn rtpPostCreateHookAdd ( - hook : RTP_POST_CREATE_HOOK, - addToHead : BOOL, - ) -> c_int; - - pub fn rtpPostCreateHookDelete ( - hook : RTP_POST_CREATE_HOOK, - ) -> c_int; - - pub fn rtpInitCompleteHookAdd ( - hook : RTP_INIT_COMPLETE_HOOK, - addToHead : BOOL, - ) -> c_int; - - pub fn rtpInitCompleteHookDelete ( - hook : RTP_INIT_COMPLETE_HOOK, - ) -> c_int; - - pub fn rtpDeleteHookAdd ( - hook : RTP_DELETE_HOOK, - addToHead : BOOL, - ) -> c_int; - - pub fn rtpDeleteHookDelete ( - hook : RTP_DELETE_HOOK, - ) -> c_int; - - pub fn rtpMemShow ( - rtpNameOrId : *mut c_char, - level : c_int, - ) -> c_int; - - pub fn rtpHookShow ( - - ); -*/ -}