mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1576168 - mach vendor rust. r=pehrsons
Differential Revision: https://phabricator.services.mozilla.com/D43403 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
c23f8dcae9
commit
75f26463c7
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -83,7 +83,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "audio_thread_priority"
|
||||
version = "0.18.0"
|
||||
version = "0.19.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -125,7 +125,7 @@ dependencies = [
|
||||
name = "audioipc-client"
|
||||
version = "0.4.0"
|
||||
dependencies = [
|
||||
"audio_thread_priority 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"audio_thread_priority 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"audioipc 0.2.4",
|
||||
"cubeb-backend 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -139,7 +139,7 @@ dependencies = [
|
||||
name = "audioipc-server"
|
||||
version = "0.2.3"
|
||||
dependencies = [
|
||||
"audio_thread_priority 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"audio_thread_priority 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"audioipc 0.2.4",
|
||||
"cubeb-core 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -1256,7 +1256,7 @@ name = "gkrust-shared"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"arrayvec 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"audio_thread_priority 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"audio_thread_priority 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"audioipc-client 0.4.0",
|
||||
"audioipc-server 0.2.3",
|
||||
"authenticator 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -3875,7 +3875,7 @@ dependencies = [
|
||||
"checksum atomic 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c210c1f4db048cda477b652d170572d84c9640695835f17663595d3bd543fc28"
|
||||
"checksum atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fb2dcb6e6d35f20276943cc04bb98e538b348d525a04ac79c10021561d202f21"
|
||||
"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652"
|
||||
"checksum audio_thread_priority 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5bf0d279b855523da1d60ea3bf145f797b92ed96190f26975730e517e7bfc7df"
|
||||
"checksum audio_thread_priority 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4c1e4aab7f57d8334168073cd0d0f11c7d1f7f3aabef84a1733a42629d0da80c"
|
||||
"checksum authenticator 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ec149e5d5d4caa2c9ead53a8ce1ea9c4204c388c65bf3b96c2d1dc0fcf4aeb66"
|
||||
"checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799"
|
||||
"checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a"
|
||||
|
@ -1 +1 @@
|
||||
{"files":{"Cargo.toml":"97400c81970be22ec890a301b1cc7fe9f6c5da66d7055e5e6b192a86fd9fdf06","README.md":"bcfa4948edf52fdacd485200a0c1c886a92232cc1931eeb4e1044050f46ec253","audio_thread_priority.h":"880889a154283a87cf84218cc4d6b2b9dd2c8fd09adc6d38f527b08ccd0c6168","generate_osx_bindings.sh":"06e4e03450f788ced18d31fff5660919e6f6ec1119ddace363ffeb82f0518a71","src/lib.rs":"d1e04bc2901472ce98be1a79b6844b49e38598eda3e4f8c0e7b08c5b33247375","src/mach_sys.rs":"352560fcb9b41d877cff92e5b3b04d6dc68b1f30508ce4b9aed78940120a883e","src/rt_linux.rs":"2cc14b5da069d2366064d5bd6d18066d24c2dce70cc1e9242fbbda55e3e9946b","src/rt_mach.rs":"14c4285c9cd3083e99ae321ece0dfe41d3b60fc56e01b1844e934009d70c857e","src/rt_win.rs":"f8f5b7af21cadd686cf7d8099d1972d3265c3889574020bd4ea088b832fbfa51"},"package":"5bf0d279b855523da1d60ea3bf145f797b92ed96190f26975730e517e7bfc7df"}
|
||||
{"files":{"Cargo.toml":"a18d74797e678c75ae36f85e15092ea4eca698f5e8a2580c3144e32f407164d4","README.md":"bcfa4948edf52fdacd485200a0c1c886a92232cc1931eeb4e1044050f46ec253","audio_thread_priority.h":"880889a154283a87cf84218cc4d6b2b9dd2c8fd09adc6d38f527b08ccd0c6168","generate_osx_bindings.sh":"06e4e03450f788ced18d31fff5660919e6f6ec1119ddace363ffeb82f0518a71","src/lib.rs":"25df84928756bc50fa908d65acace5259b59dfa5fc57a3f0f8b0e1f8a98ab512","src/mach_sys.rs":"352560fcb9b41d877cff92e5b3b04d6dc68b1f30508ce4b9aed78940120a883e","src/rt_linux.rs":"3da1550beacc8f8a0d86c07ed190ceef7d56398c675b99a145919f5c7231eed7","src/rt_mach.rs":"5fce324b9a64305ff221fdd185eaa4b1c7386b6e61edc32cf63e424f9f3d90ef","src/rt_win.rs":"f8f5b7af21cadd686cf7d8099d1972d3265c3889574020bd4ea088b832fbfa51"},"package":"4c1e4aab7f57d8334168073cd0d0f11c7d1f7f3aabef84a1733a42629d0da80c"}
|
@ -11,8 +11,9 @@
|
||||
# will likely look very different (and much more reasonable)
|
||||
|
||||
[package]
|
||||
edition = "2018"
|
||||
name = "audio_thread_priority"
|
||||
version = "0.18.0"
|
||||
version = "0.19.1"
|
||||
authors = ["Paul Adenot <paul@paul.cx>"]
|
||||
description = "Bump a thread to real-time priority, for audio work, on Linux, Windows and macOS"
|
||||
license = "MPL-2.0"
|
||||
|
@ -163,15 +163,14 @@ pub extern "C" fn atp_free_handle(handle: *mut atp_handle) -> i32 {
|
||||
0
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
#[cfg(feature = "terminal-logging")]
|
||||
use simple_logger;
|
||||
#[test]
|
||||
#[test]
|
||||
fn it_works() {
|
||||
#[cfg(feature = "terminal-logging")]
|
||||
#[cfg(feature = "terminal-logging")]
|
||||
simple_logger::init().unwrap();
|
||||
{
|
||||
assert!(promote_current_thread_to_real_time(0, 0).is_err());
|
||||
@ -198,7 +197,7 @@ mod tests {
|
||||
}
|
||||
{
|
||||
match promote_current_thread_to_real_time(512, 44100) {
|
||||
Ok(_) => { }
|
||||
Ok(_) => {}
|
||||
Err(e) => {
|
||||
panic!(e);
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ extern crate dbus;
|
||||
extern crate libc;
|
||||
|
||||
use std::cmp;
|
||||
use std::error::Error;
|
||||
|
||||
use dbus::{Connection, BusType, Props, MessageItem, Message};
|
||||
|
||||
@ -27,7 +28,7 @@ pub struct RtPriorityHandleInternal {
|
||||
param: libc::sched_param,
|
||||
}
|
||||
|
||||
fn item_as_i64(i: MessageItem) -> Result<i64, Box<std::error::Error>> {
|
||||
fn item_as_i64(i: MessageItem) -> Result<i64, Box<dyn Error>> {
|
||||
match i {
|
||||
MessageItem::Int32(i) => Ok(i as i64),
|
||||
MessageItem::Int64(i) => Ok(i),
|
||||
@ -35,7 +36,7 @@ fn item_as_i64(i: MessageItem) -> Result<i64, Box<std::error::Error>> {
|
||||
}
|
||||
}
|
||||
|
||||
fn rtkit_set_realtime(c: &Connection, thread: u64, prio: u32) -> Result<(), Box<std::error::Error>> {
|
||||
fn rtkit_set_realtime(c: &Connection, thread: u64, prio: u32) -> Result<(), Box<dyn Error>> {
|
||||
let mut m = Message::new_method_call("org.freedesktop.RealtimeKit1",
|
||||
"/org/freedesktop/RealtimeKit1",
|
||||
"org.freedesktop.RealtimeKit1",
|
||||
@ -45,7 +46,7 @@ fn rtkit_set_realtime(c: &Connection, thread: u64, prio: u32) -> Result<(), Box<
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
fn make_realtime(tid: kernel_pid_t, max_slice_us: u64, prio: u32) -> Result<u32, Box<std::error::Error>> {
|
||||
fn make_realtime(tid: kernel_pid_t, requested_slice_us: u64, prio: u32) -> Result<u32, Box<dyn Error>> {
|
||||
let c = Connection::get_private(BusType::System)?;
|
||||
|
||||
let p = Props::new(&c, "org.freedesktop.RealtimeKit1", "/org/freedesktop/RealtimeKit1",
|
||||
@ -65,10 +66,12 @@ fn make_realtime(tid: kernel_pid_t, max_slice_us: u64, prio: u32) -> Result<u32,
|
||||
}
|
||||
|
||||
// Only take what we need, or cap at the system limit, no further.
|
||||
let rttime_request = cmp::min(max_slice_us, max_rttime as u64);
|
||||
let rttime_request = cmp::min(requested_slice_us, max_rttime as u64);
|
||||
|
||||
// Set a soft limit to the limit requested, to be able to handle going over the limit using
|
||||
// SIXCPU. Set the hard limit to the maxium slice to prevent getting SIGKILL.
|
||||
let new_limit = libc::rlimit64 { rlim_cur: rttime_request,
|
||||
rlim_max: rttime_request };
|
||||
rlim_max: max_rttime as u64 };
|
||||
let mut old_limit = new_limit;
|
||||
if unsafe { libc::getrlimit64(libc::RLIMIT_RTTIME, &mut old_limit) } < 0 {
|
||||
return Err(Box::from("getrlimit failed"));
|
||||
|
@ -5,7 +5,7 @@
|
||||
use mach::kern_return::{kern_return_t, KERN_SUCCESS};
|
||||
use mach::port::mach_port_t;
|
||||
use mach::message::mach_msg_type_number_t;
|
||||
use mach_sys::*;
|
||||
use crate::mach_sys::*;
|
||||
use std::mem::size_of;
|
||||
use mach::mach_time::{mach_timebase_info_data_t, mach_timebase_info};
|
||||
use libc::{pthread_t, pthread_self};
|
||||
|
Loading…
Reference in New Issue
Block a user