summaryrefslogtreecommitdiff
path: root/src/helper/binarybuffer.c
diff options
context:
space:
mode:
authordrath <drath@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2006-07-17 14:13:27 +0000
committerdrath <drath@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2006-07-17 14:13:27 +0000
commit82d2633b5f550115e9e7c7d0520babb6680aa38f (patch)
treefa9895a6117d4a238be1b76293edcc7de11a88c2 /src/helper/binarybuffer.c
parent1960973baf8022b4525e3ac94aed8dace7f9b478 (diff)
downloadopenocd+libswd-82d2633b5f550115e9e7c7d0520babb6680aa38f.tar.gz
openocd+libswd-82d2633b5f550115e9e7c7d0520babb6680aa38f.tar.bz2
openocd+libswd-82d2633b5f550115e9e7c7d0520babb6680aa38f.tar.xz
openocd+libswd-82d2633b5f550115e9e7c7d0520babb6680aa38f.zip
- 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
Diffstat (limited to 'src/helper/binarybuffer.c')
-rw-r--r--src/helper/binarybuffer.c32
1 files changed, 28 insertions, 4 deletions
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 <stdlib.h>
#include <string.h>
@@ -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;