From 79075f9e81d9d56be5da3bf6cdae56f4ace950de Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 19 Mar 2010 12:48:54 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1755 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chschd.h | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'os/kernel/include') diff --git a/os/kernel/include/chschd.h b/os/kernel/include/chschd.h index d1b69cad5..3847c948e 100644 --- a/os/kernel/include/chschd.h +++ b/os/kernel/include/chschd.h @@ -92,11 +92,33 @@ typedef struct { extern ReadyList rlist; #endif /* !defined(PORT_OPTIMIZED_RLIST_EXT) */ -#ifdef CH_CURRP_REGISTER_CACHE -register Thread *currp asm(CH_CURRP_REGISTER_CACHE); -#else +/** + * @brief Current thread pointer access macro. + * @note This macro is not meant to be used in the application code but + * only from within the kernel, use the @p chThdSelf() API instead. + * @note It is forbidden to use this macro in order to change the pointer + * (currp = something), use @p setcurrp() instead. + */ +#if !defined(PORT_OPTIMIZED_CURRP) || defined(__DOXYGEN__) +#if !defined(CH_CURRP_REGISTER_CACHE) || defined(__DOXYGEN__) #define currp rlist.r_current -#endif +#else /* defined(CH_CURRP_REGISTER_CACHE) */ +register Thread *currp asm(CH_CURRP_REGISTER_CACHE); +#endif /* defined(CH_CURRP_REGISTER_CACHE) */ +#endif /* !defined(PORT_OPTIMIZED_CURRP) */ + +/** + * @brief Current thread pointer change macro. + * @note This macro is not meant to be used in the application code but + * only from within the kernel. + */ +#if !defined(PORT_OPTIMIZED_SETCURRP) || defined(__DOXYGEN__) +#if !defined(CH_CURRP_REGISTER_CACHE) || defined(__DOXYGEN__) +#define setcurrp(tp) (rlist.r_current = (tp)) +#else /* defined(CH_CURRP_REGISTER_CACHE) */ +(currp = (tp)) +#endif /* defined(CH_CURRP_REGISTER_CACHE) */ +#endif /* !defined(PORT_OPTIMIZED_SETCURRP) */ /* * Scheduler APIs. @@ -135,7 +157,7 @@ extern "C" { * @details This function returns @p TRUE if there is a ready thread with * higher priority. */ -#if !defined(PORT_OPTIMIZED_ISRESCHREQUIREDI) && !defined(__DOXYGEN__) +#if !defined(PORT_OPTIMIZED_ISRESCHREQUIREDI) || defined(__DOXYGEN__) #define chSchIsRescRequiredI() (firstprio(&rlist.r_queue) > currp->p_prio) #endif /* !defined(PORT_OPTIMIZED_ISRESCHREQUIREDI) */ @@ -144,7 +166,7 @@ extern "C" { * @details This function returns @p TRUE if there is a ready thread with * equal or higher priority. */ -#if !defined(PORT_OPTIMIZED_CANYIELDS) && !defined(__DOXYGEN__) +#if !defined(PORT_OPTIMIZED_CANYIELDS) || defined(__DOXYGEN__) #define chSchCanYieldS() (firstprio(&rlist.r_queue) >= currp->p_prio) #endif /* !defined(PORT_OPTIMIZED_CANYIELDS) */ -- cgit v1.2.3