From acb2736f67b2134e72dc6a338457a46c2172ac21 Mon Sep 17 00:00:00 2001 From: AzureMarker Date: Tue, 15 Feb 2022 21:42:46 -0800 Subject: [PATCH] Avoid using svcGetThreadList when getting default pthread attr This simplifies the code anyway. --- src/lib.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b4197c8..4dc7591 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -224,19 +224,16 @@ struct PThreadAttr { impl Default for PThreadAttr { fn default() -> Self { - let thread_id = unsafe { libc::pthread_self() }; - let mut policy = 0; - let mut sched_param = libc::sched_param { sched_priority: 0 }; - - unsafe { libc::pthread_getschedparam(thread_id, &mut policy, &mut sched_param) }; - - let priority = sched_param.sched_priority; + // Note: we are ignoring the result here, but errors shouldn't occur + // since we're using a valid handle. + let mut priority = 0; + unsafe { ctru_sys::svcGetThreadPriority(&mut priority, ctru_sys::CUR_THREAD_HANDLE) }; PThreadAttr { stack_size: libc::PTHREAD_STACK_MIN, - // If no priority value is specified, spawn with the same - // priority as the current thread + // If no priority value is specified, spawn with the same priority + // as the current thread priority, // If no processor is specified, spawn on the default core.