Skip to content

Commit

Permalink
Fix hrtimer tests on MacOS (mozilla#1517)
Browse files Browse the repository at this point in the history
Whatever I did to this file in mozilla#1512 made the tests on MacOS fail
(because timer accuracy got bad.) Restoring the code and adding
clippy ignores fixes this.
  • Loading branch information
larseggert authored Dec 14, 2023
1 parent d1825f4 commit d3489df
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions neqo-common/src/hrtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,13 @@ mod mac {
#[repr(C)]
#[derive(Debug, Copy, Clone, Default)]
pub struct thread_time_constraint_policy {
period: f64,
computation: f64,
constraint: f64,
period: u32,
computation: u32,
constraint: u32,
preemptible: boolean_t,
}

const THREAD_TIME_CONSTRAINT_POLICY: thread_policy_flavor_t = 2;

#[allow(clippy::cast_possible_truncation)]
const THREAD_TIME_CONSTRAINT_POLICY_COUNT: mach_msg_type_number_t =
(size_of::<thread_time_constraint_policy>() / size_of::<integer_t>())
Expand Down Expand Up @@ -182,10 +181,11 @@ mod mac {

/// Create a realtime policy and set it.
pub fn set_realtime(base: f64) {
#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
let policy = thread_time_constraint_policy {
period: base, // Base interval
computation: base * 0.5,
constraint: base,
period: base as u32, // Base interval
computation: (base * 0.5) as u32,
constraint: (base * 1.0) as u32,
preemptible: 1,
};
set_thread_policy(policy);
Expand Down

0 comments on commit d3489df

Please sign in to comment.