Opened on 11/08/11 at 20:38:14
Closed on 11/09/11 at 17:53:27
#1954 closed defect (fixed)
Incorrect macro expansion in lm32.h
Reported by: | seb | Owned by: | Joel Sherrill |
---|---|---|---|
Priority: | normal | Milestone: | 4.11 |
Component: | score | Version: | 4.11 |
Severity: | critical | Keywords: | |
Cc: | Blocked By: | ||
Blocking: |
Description
(from Werner Almesberger)
I've been complaining about sloppy use of macros a few time.
In lm32.h, the chicken are finally coming home to roost.
What happened there was that in one case an
lm32_interrupt_mask(1 << X)
turned into
im &= ~1 << X;
while it should be
im &= ~(1 << X);
This patch adds proper protection to the arguments. This makes the
"lag" (which was in fact the disabling of the interrupt that made
system time tick) disappear.
There are some more things that are odd but not incorrect, such as
the parentheses around ~0x0001, so I didn't touch them.
- Werner
Index: cpukit/score/cpu/lm32/rtems/score/lm32.h
===================================================================
RCS file: /usr1/CVS/rtems/cpukit/score/cpu/lm32/rtems/score/lm32.h,v
retrieving revision 1.4
diff -u -r1.4 lm32.h
--- cpukit/score/cpu/lm32/rtems/score/lm32.h 11 Feb 2011 08:57:36 -0000 1.4
+++ cpukit/score/cpu/lm32/rtems/score/lm32.h 8 Nov 2011 18:27:45 -0000
@@ -74,7 +74,7 @@
#define lm32_disable_interrupts( _level ) \
do { register uint32_t ie; \
asm volatile ("rcsr %0,ie":"=r"(ie)); \
- _level = ie; \
+ (_level) = ie; \
ie &= (~0x0001); \
asm volatile ("wcsr ie,%0"::"r"(ie)); \
} while (0)
@@ -85,7 +85,7 @@
#define lm32_flash_interrupts( _level ) \
do { register uint32_t ie; \
asm volatile ("wcsr ie,%0"::"r"(_level)); \
- ie = _level & (~0x0001); \
+ ie = (_level) & (~0x0001); \
asm volatile ("wcsr ie,%0"::"r"(ie)); \
} while (0)
@@ -99,7 +99,7 @@
#define lm32_interrupt_mask( _mask ) \
do { register uint32_t im; \
asm volatile ("rcsr %0,im":"=r"(im)); \
- im &= ~_mask; \
+ im &= ~(_mask); \
asm volatile ("wcsr im,%0"::"r"(im)); \
} while (0)
Change History (2)
comment:1 Changed on 11/09/11 at 17:53:27 by Joel Sherrill
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:2 Changed on 11/24/14 at 18:58:28 by Gedare Bloom
Version: | HEAD → 4.11 |
---|
Replace Version=HEAD with Version=4.11 for the tickets with Milestone >= 4.11
This one applied cleanly but I had to make the changes to 4.10 manually.
Applied. Closing. Thanks.