<div dir="auto">Anything to add to the message beyond "fix" to explain this patch? :)<div dir="auto"><br></div><div dir="auto">I think the software engineering guide uses a comment similar to this as an anti-pattern. Lol</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 11, 2023, 12:00 AM <<a href="mailto:chrisj@rtems.org">chrisj@rtems.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Chris Johns <<a href="mailto:chrisj@rtems.org" target="_blank" rel="noreferrer">chrisj@rtems.org</a>><br>
<br>
---<br>
bsps/powerpc/include/libcpu/powerpc-utility.h | 40 +++++++++++--------<br>
.../powerpc/shared/exceptions/ppc_exc_print.c | 25 +++++++-----<br>
2 files changed, 38 insertions(+), 27 deletions(-)<br>
<br>
diff --git a/bsps/powerpc/include/libcpu/powerpc-utility.h b/bsps/powerpc/include/libcpu/powerpc-utility.h<br>
index 922e5d2407..fb831c9fa8 100644<br>
--- a/bsps/powerpc/include/libcpu/powerpc-utility.h<br>
+++ b/bsps/powerpc/include/libcpu/powerpc-utility.h<br>
@@ -577,15 +577,11 @@ static inline void ppc_set_decrementer_register(uint32_t dec)<br>
*<br>
* @note This macro uses a GNU C extension.<br>
*/<br>
-#define PPC_SPECIAL_PURPOSE_REGISTER(spr) \<br>
- ({ \<br>
- uint32_t val; \<br>
- __asm__ volatile (\<br>
- "mfspr %0, " PPC_STRINGOF(spr) \<br>
- : "=r" (val) \<br>
- ); \<br>
- val;\<br>
- } )<br>
+#define PPC_SPECIAL_PURPOSE_REGISTER(spr, val) \<br>
+ __asm__ volatile (\<br>
+ "mfspr %0, " PPC_STRINGOF(spr) \<br>
+ : "=r" (val) \<br>
+ )<br>
<br>
/**<br>
* @brief Sets the Special Purpose Register with number @a spr to the value in<br>
@@ -612,7 +608,7 @@ static inline void ppc_set_decrementer_register(uint32_t dec)<br>
uint32_t val; \<br>
uint32_t mybits = bits; \<br>
_ISR_Local_disable(level); \<br>
- val = PPC_SPECIAL_PURPOSE_REGISTER(spr); \<br>
+ PPC_SPECIAL_PURPOSE_REGISTER(spr, val); \<br>
val |= mybits; \<br>
PPC_SET_SPECIAL_PURPOSE_REGISTER(spr, val); \<br>
_ISR_Local_enable(level); \<br>
@@ -632,7 +628,7 @@ static inline void ppc_set_decrementer_register(uint32_t dec)<br>
uint32_t mybits = bits; \<br>
uint32_t mymask = mask; \<br>
_ISR_Local_disable(level); \<br>
- val = PPC_SPECIAL_PURPOSE_REGISTER(spr); \<br>
+ PPC_SPECIAL_PURPOSE_REGISTER(spr, val); \<br>
val &= ~mymask; \<br>
val |= mybits; \<br>
PPC_SET_SPECIAL_PURPOSE_REGISTER(spr, val); \<br>
@@ -651,7 +647,7 @@ static inline void ppc_set_decrementer_register(uint32_t dec)<br>
uint32_t val; \<br>
uint32_t mybits = bits; \<br>
_ISR_Local_disable(level); \<br>
- val = PPC_SPECIAL_PURPOSE_REGISTER(spr); \<br>
+ PPC_SPECIAL_PURPOSE_REGISTER(spr, val); \<br>
val &= ~mybits; \<br>
PPC_SET_SPECIAL_PURPOSE_REGISTER(spr, val); \<br>
_ISR_Local_enable(level); \<br>
@@ -790,7 +786,9 @@ static inline void ppc_set_time_base(uint32_t val)<br>
<br>
static inline uint32_t ppc_time_base_upper(void)<br>
{<br>
- return PPC_SPECIAL_PURPOSE_REGISTER(TBRU);<br>
+ uint32_t val;<br>
+ PPC_SPECIAL_PURPOSE_REGISTER(TBRU, val);<br>
+ return val;<br>
}<br>
<br>
static inline void ppc_set_time_base_upper(uint32_t val)<br>
@@ -810,12 +808,16 @@ static inline void ppc_set_time_base_64(uint64_t val)<br>
<br>
static inline uint32_t ppc_alternate_time_base(void)<br>
{<br>
- return PPC_SPECIAL_PURPOSE_REGISTER(FSL_EIS_ATBL);<br>
+ uint32_t val;<br>
+ PPC_SPECIAL_PURPOSE_REGISTER(FSL_EIS_ATBL, val);<br>
+ return val;<br>
}<br>
<br>
static inline uint32_t ppc_alternate_time_base_upper(void)<br>
{<br>
- return PPC_SPECIAL_PURPOSE_REGISTER(FSL_EIS_ATBU);<br>
+ uint32_t val;<br>
+ PPC_SPECIAL_PURPOSE_REGISTER(FSL_EIS_ATBU, val);<br>
+ return val;<br>
}<br>
<br>
static inline uint64_t ppc_alternate_time_base_64(void)<br>
@@ -835,7 +837,9 @@ static inline uint64_t ppc_alternate_time_base_64(void)<br>
<br>
static inline uint32_t ppc_processor_id(void)<br>
{<br>
- return PPC_SPECIAL_PURPOSE_REGISTER(BOOKE_PIR);<br>
+ uint32_t val;<br>
+ PPC_SPECIAL_PURPOSE_REGISTER(BOOKE_PIR, val);<br>
+ return val;<br>
}<br>
<br>
static inline void ppc_set_processor_id(uint32_t val)<br>
@@ -845,7 +849,9 @@ static inline void ppc_set_processor_id(uint32_t val)<br>
<br>
static inline uint32_t ppc_fsl_system_version(void)<br>
{<br>
- return PPC_SPECIAL_PURPOSE_REGISTER(FSL_EIS_SVR);<br>
+ uint32_t val;<br>
+ PPC_SPECIAL_PURPOSE_REGISTER(FSL_EIS_SVR, val);<br>
+ return val;<br>
}<br>
<br>
static inline uint32_t ppc_fsl_system_version_cid(uint32_t svr)<br>
diff --git a/bsps/powerpc/shared/exceptions/ppc_exc_print.c b/bsps/powerpc/shared/exceptions/ppc_exc_print.c<br>
index e4fcc73cb1..ff231beff9 100644<br>
--- a/bsps/powerpc/shared/exceptions/ppc_exc_print.c<br>
+++ b/bsps/powerpc/shared/exceptions/ppc_exc_print.c<br>
@@ -42,18 +42,23 @@ typedef struct LRFrameRec_ {<br>
<br>
static uint32_t ppc_exc_get_DAR_dflt(void)<br>
{<br>
- if (ppc_cpu_is_60x())<br>
- return PPC_SPECIAL_PURPOSE_REGISTER(PPC_DAR);<br>
- else<br>
+ uint32_t val;<br>
+ if (ppc_cpu_is_60x()) {<br>
+ PPC_SPECIAL_PURPOSE_REGISTER(PPC_DAR, val);<br>
+ return val;<br>
+ } else {<br>
switch (ppc_cpu_is_bookE()) {<br>
default:<br>
break;<br>
case PPC_BOOKE_STD:<br>
case PPC_BOOKE_E500:<br>
- return PPC_SPECIAL_PURPOSE_REGISTER(BOOKE_DEAR);<br>
+ PPC_SPECIAL_PURPOSE_REGISTER(BOOKE_DEAR, val);<br>
+ return val;<br>
case PPC_BOOKE_405:<br>
- return PPC_SPECIAL_PURPOSE_REGISTER(PPC405_DEAR);<br>
+ PPC_SPECIAL_PURPOSE_REGISTER(PPC405_DEAR, val);<br>
+ return val;<br>
}<br>
+ }<br>
return 0xdeadbeef;<br>
}<br>
<br>
@@ -170,13 +175,13 @@ void _CPU_Exception_frame_print(const CPU_Exception_frame *excPtr)<br>
printk(" %s = 0x%08" PRIx32 "\n", reg, ppc_exc_get_DAR());<br>
}<br>
if (ppc_cpu_is_bookE()) {<br>
- unsigned esr, mcsr;<br>
+ uint32_t esr, mcsr;<br>
if (ppc_cpu_is_bookE() == PPC_BOOKE_405) {<br>
- esr = PPC_SPECIAL_PURPOSE_REGISTER(PPC405_ESR);<br>
- mcsr = PPC_SPECIAL_PURPOSE_REGISTER(PPC405_MCSR);<br>
+ PPC_SPECIAL_PURPOSE_REGISTER(PPC405_ESR, esr);<br>
+ PPC_SPECIAL_PURPOSE_REGISTER(PPC405_MCSR, mcsr);<br>
} else {<br>
- esr = PPC_SPECIAL_PURPOSE_REGISTER(BOOKE_ESR);<br>
- mcsr = PPC_SPECIAL_PURPOSE_REGISTER(BOOKE_MCSR);<br>
+ PPC_SPECIAL_PURPOSE_REGISTER(BOOKE_ESR, esr);<br>
+ PPC_SPECIAL_PURPOSE_REGISTER(BOOKE_MCSR, mcsr);<br>
}<br>
printk(" ESR = 0x%08x\n", esr);<br>
printk(" MCSR = 0x%08x\n", mcsr);<br>
-- <br>
2.37.1<br>
<br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank" rel="noreferrer">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
</blockquote></div>