From 82d2633b5f550115e9e7c7d0520babb6680aa38f Mon Sep 17 00:00:00 2001 From: drath Date: Mon, 17 Jul 2006 14:13:27 +0000 Subject: - Added support for native MinGW builds (thanks to Spencer Oliver and Michael Fischer) - you still need to install GiveIO (not part of OpenOCD) - Added state-move support to ftd2xx and bitbang JTAG drivers (required for XScale, possibly useful for other targets, too) - various fixes git-svn-id: svn://svn.berlios.de/openocd/trunk@78 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- src/helper/binarybuffer.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'src/helper/binarybuffer.c') diff --git a/src/helper/binarybuffer.c b/src/helper/binarybuffer.c index 357d05c3..ce33f138 100644 --- a/src/helper/binarybuffer.c +++ b/src/helper/binarybuffer.c @@ -17,6 +17,9 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include #include @@ -112,8 +115,18 @@ int buf_cmp(u8 *buf1, u8 *buf2, int size) for (i = 0; i < num_bytes; i++) { - if (buf1[i] != buf2[i]) - return 1; + /* last byte */ + /* mask out bits that don't really belong to the buffer if size isn't a multiple of 8 bits */ + if ((size % 8) && (i == num_bytes -1 )) + { + if ((buf1[i] & ((1 << (size % 8)) - 1)) != (buf2[i] & ((1 << (size % 8)) - 1))) + return 1; + } + else + { + if (buf1[i] != buf2[i]) + return 1; + } } return 0; @@ -126,8 +139,19 @@ int buf_cmp_mask(u8 *buf1, u8 *buf2, u8 *mask, int size) for (i = 0; i < num_bytes; i++) { - if ((buf1[i] & mask[i]) != (buf2[i] & mask[i])) - return 1; + /* last byte */ + /* mask out bits that don't really belong to the buffer if size isn't a multiple of 8 bits */ + if ((size % 8) && (i == num_bytes -1 )) + { + if (((buf1[i] & ((1 << (size % 8)) - 1)) & ((1 << (size % 8)) - 1)) != + ((buf2[i] & ((1 << (size % 8)) - 1)) & ((1 << (size % 8)) - 1))) + return 1; + } + else + { + if ((buf1[i] & mask[i]) != (buf2[i] & mask[i])) + return 1; + } } return 0; -- cgit v1.2.3