CPU_swap_u16 is a macro, with all the problems that entails,
such as:

- multiple evaluation of the argument,
- tricky type semantics, and last but not least
- the need to protect arguments

The lack of the latter is a bug, though I don't think it had any
real-life impact on M1 behaviour this far.

Converting this to an inline function solves all these issues.

- Werner

Index: cpukit/score/cpu/lm32/rtems/score/cpu.h
===================================================================
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/lm32/rtems/score/cpu.h,v
retrieving revision 1.14
diff -u -r1.14 cpu.h
--- cpukit/score/cpu/lm32/rtems/score/cpu.h     27 Sep 2011 09:17:02 -0000      
1.14
+++ cpukit/score/cpu/lm32/rtems/score/cpu.h     8 Nov 2011 18:27:45 -0000
@@ -1258,8 +1258,10 @@
  *  @param[in] value is the value to be swapped
  *  @return the value after being endian swapped
  */
-#define CPU_swap_u16( value ) \
-  (((value&0xff) << 8) | ((value >> 8)&0xff))
+static inline uint16_t CPU_swap_u16(uint16_t v)
+{
+       return v << 8 | v >> 8;
+}
 
 #ifdef __cplusplus
 }
_______________________________________________
http://lists.milkymist.org/listinfo.cgi/devel-milkymist.org
IRC: #milkymist@Freenode

Reply via email to