From: Eric Nelson <eric.nelson@boundarydevices.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] itest: Add bitwise and operator
Date: Fri, 3 May 2013 11:47:42 -0700 [thread overview]
Message-ID: <1367606863-14846-1-git-send-email-eric.nelson@boundarydevices.com> (raw)
Signed-off-by: Eric Nelson <eric.nelson@boundarydevices.com>
---
common/cmd_itest.c | 4 ++++
doc/README.commands.itest | 10 +++++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/common/cmd_itest.c b/common/cmd_itest.c
index 2c8e5d0..0629b09 100644
--- a/common/cmd_itest.c
+++ b/common/cmd_itest.c
@@ -38,6 +38,7 @@
#define GT 3
#define LE 4
#define GE 5
+#define AND 6
struct op_tbl_s {
char *op; /* operator string */
@@ -60,6 +61,8 @@ static const op_tbl_t op_table [] = {
{ ">=" , GE },
{ "-le", LE },
{ "<=" , LE },
+ { "-and", AND },
+ { "&" , AND },
};
static long evalexp(char *s, int w)
@@ -126,6 +129,7 @@ static int arithcomp (char *s, char *t, int op, int w)
case GT: return (l > r);
case LE: return (l <= r);
case GE: return (l >= r);
+ case AND: return (l & r);
}
return (0);
}
diff --git a/doc/README.commands.itest b/doc/README.commands.itest
index 5e0fe86..0058155 100644
--- a/doc/README.commands.itest
+++ b/doc/README.commands.itest
@@ -2,7 +2,7 @@ A slow day today so here is a revised itest command with provisional
support for comparing strings as well :-))
Now table driven to allow the operators
--eq, -ne, -lt, -gt, -le, -ge, ==, !=, <>, <, >, <=, >=
+-eq, -ne, -lt, -gt, -le, -ge, -and, ==, !=, <>, <, >, <=, >=, &
Uses the expected command modifier for integer compares of width 1, 2 or
4 bytes of .b, .w, .l and the new modifer of .s for a string compare.
@@ -14,3 +14,11 @@ if itest.l *40000 == 12345678 then; ....
if itest.w *40000 != 1234 then; ....
if itest.b *40000 >= 12 then; ....
if itest.s *40000 -eq hello then; ....
+
+Note that "&" (-and) operator only operates on integers and
+that the '&' will need to be quoted.
+
+e.g.:
+ if itest.l 0x80 '&' *0x020D8044 then; ...
+or
+ if itest.l 0x80 -and *0x020D8044 then; ...
--
1.7.9.5
next reply other threads:[~2013-05-03 18:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-03 18:47 Eric Nelson [this message]
2013-05-03 19:08 ` [U-Boot] [PATCH] itest: Add bitwise and operator Wolfgang Denk
2013-05-03 19:22 ` Eric Nelson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1367606863-14846-1-git-send-email-eric.nelson@boundarydevices.com \
--to=eric.nelson@boundarydevices.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox