gpui: Fix use of libc::sched_param on musl (#44846)
Release Notes: - N/A *or* Added/Fixed/Improved ...
This commit is contained in:
@@ -1,18 +1,21 @@
|
||||
use crate::{
|
||||
GLOBAL_THREAD_TIMINGS, PlatformDispatcher, Priority, PriorityQueueReceiver,
|
||||
PriorityQueueSender, RealtimePriority, RunnableVariant, THREAD_TIMINGS, TaskLabel, TaskTiming,
|
||||
ThreadTaskTimings, profiler,
|
||||
};
|
||||
use calloop::{
|
||||
EventLoop, PostAction,
|
||||
channel::{self, Sender},
|
||||
timer::TimeoutAction,
|
||||
};
|
||||
use util::ResultExt;
|
||||
|
||||
use std::{
|
||||
mem::MaybeUninit,
|
||||
thread,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
use util::ResultExt;
|
||||
|
||||
use crate::{
|
||||
GLOBAL_THREAD_TIMINGS, PlatformDispatcher, Priority, PriorityQueueReceiver,
|
||||
PriorityQueueSender, RealtimePriority, RunnableVariant, THREAD_TIMINGS, TaskLabel, TaskTiming,
|
||||
ThreadTaskTimings, profiler,
|
||||
};
|
||||
|
||||
struct TimerAfter {
|
||||
duration: Duration,
|
||||
@@ -228,7 +231,10 @@ impl PlatformDispatcher for LinuxDispatcher {
|
||||
RealtimePriority::Other => 45,
|
||||
};
|
||||
|
||||
let sched_param = libc::sched_param { sched_priority };
|
||||
// SAFETY: all sched_param members are valid when initialized to zero.
|
||||
let mut sched_param =
|
||||
unsafe { MaybeUninit::<libc::sched_param>::zeroed().assume_init() };
|
||||
sched_param.sched_priority = sched_priority;
|
||||
// SAFETY: sched_param is a valid initialized structure
|
||||
let result = unsafe { libc::pthread_setschedparam(thread_id, policy, &sched_param) };
|
||||
if result != 0 {
|
||||
|
||||
Reference in New Issue
Block a user