From 8d2b894d88f822624a1e5bf01b4324a01ae1fc06 Mon Sep 17 00:00:00 2001 From: Extrems Date: Wed, 22 May 2024 14:00:57 -0400 Subject: [PATCH] Add LWP_GetThreadPriority Co-authored-by: Exortile --- gc/ogc/lwp.h | 9 +++++++++ libogc/lwp.c | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/gc/ogc/lwp.h b/gc/ogc/lwp.h index 81b8490b..cdb1a94f 100644 --- a/gc/ogc/lwp.h +++ b/gc/ogc/lwp.h @@ -118,6 +118,15 @@ BOOL LWP_ThreadIsSuspended(lwp_t thethread); lwp_t LWP_GetSelf(void); +/*! \fn s32 LWP_GetThreadPriority(lwp_t thethread) +\brief Get the priority of the given thread. +\param[in] thethread handle to the thread context whos priority should be returned. If NULL, the current thread will be taken. + +\return 0 on success, <0 on error +*/ +s32 LWP_GetThreadPriority(lwp_t thethread); + + /*! \fn void LWP_SetThreadPriority(lwp_t thethread,u32 prio) \brief Set the priority of the given thread. \param[in] thethread handle to the thread context whos priority should be changed. If NULL, the current thread will be taken. diff --git a/libogc/lwp.c b/libogc/lwp.c index d363838d..fb3a7c07 100644 --- a/libogc/lwp.c +++ b/libogc/lwp.c @@ -265,6 +265,22 @@ lwp_t LWP_GetSelf(void) return ret; } +s32 LWP_GetThreadPriority(lwp_t thethread) +{ + u32 prio; + lwp_cntrl *lwp_thread; + + if(thethread==LWP_THREAD_NULL) thethread = LWP_GetSelf(); + + lwp_thread = __lwp_cntrl_open(thethread); + if(!lwp_thread) return -1; + + prio = __lwp_priotocore(lwp_thread->cur_prio); + + __lwp_thread_dispatchenable(); + return prio; +} + void LWP_SetThreadPriority(lwp_t thethread,u32 prio) { lwp_cntrl *lwp_thread;