diff options
author | Øyvind Harboe <oyvind.harboe@zylin.com> | 2009-11-12 10:10:11 +0100 |
---|---|---|
committer | Øyvind Harboe <oyvind.harboe@zylin.com> | 2009-11-17 15:04:17 +0100 |
commit | 83104648e6a1834244eb1b1bb6324f729532906c (patch) | |
tree | 28de3f4ccc64bd0475389be9233717337eb42566 | |
parent | b888b63fe9bee26e567a645f6ceb10d66bfff785 (diff) | |
download | openocd+libswd-83104648e6a1834244eb1b1bb6324f729532906c.tar.gz openocd+libswd-83104648e6a1834244eb1b1bb6324f729532906c.tar.bz2 openocd+libswd-83104648e6a1834244eb1b1bb6324f729532906c.tar.xz openocd+libswd-83104648e6a1834244eb1b1bb6324f729532906c.zip |
zy1000: fix bug when running on non-arm CPU
Shifting by more than 32 is undefined for 32 bit integers according
to the C standard. Robust solution is conditional code.
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
-rw-r--r-- | src/jtag/zy1000/zy1000.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/jtag/zy1000/zy1000.c b/src/jtag/zy1000/zy1000.c index 9a5d2e78..f2a5aa94 100644 --- a/src/jtag/zy1000/zy1000.c +++ b/src/jtag/zy1000/zy1000.c @@ -509,7 +509,14 @@ static __inline void scanFields(int num_fields, const struct scan_field *fields, } } /* mask away unused bits for easier debugging */ - value&=~(((uint32_t)0xffffffff) << k); + if (k < 32) + { + value&=~(((uint32_t)0xffffffff) << k); + } else + { + /* Shifting by >= 32 is not defined by the C standard + * and will in fact shift by &0x1f bits on nios */ + } shiftValueInner(shiftState, pause_state, k, value); |