[DTrace-devel] [PATCH 12/13] Fix bitwise negation

eugene.loh at oracle.com eugene.loh at oracle.com
Wed Dec 2 10:54:57 PST 2020


From: Eugene Loh <eugene.loh at oracle.com>

Orabug: 32125018
Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
 libdtrace/dt_cg.c                     | 2 +-
 test/unittest/arithmetic/tst.basics.d | 6 ++++++
 test/unittest/arithmetic/tst.basics.r | 4 ++++
 test/unittest/types/tst.assignops.d   | 1 -
 test/unittest/types/tst.unaryop.d     | 1 -
 5 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
index 43edb363..3a965265 100644
--- a/libdtrace/dt_cg.c
+++ b/libdtrace/dt_cg.c
@@ -2565,7 +2565,7 @@ dt_cg_node(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
 	case DT_TOK_BNEG:
 		dt_cg_node(dnp->dn_child, dlp, drp);
 		dnp->dn_reg = dnp->dn_child->dn_reg;
-		emit(dlp, BPF_ALU64_IMM(BPF_XOR, dnp->dn_reg, 0));
+		emit(dlp, BPF_ALU64_IMM(BPF_XOR, dnp->dn_reg, -1));
 		break;
 
 	case DT_TOK_PREINC:
diff --git a/test/unittest/arithmetic/tst.basics.d b/test/unittest/arithmetic/tst.basics.d
index 300a0079..587b7f5a 100644
--- a/test/unittest/arithmetic/tst.basics.d
+++ b/test/unittest/arithmetic/tst.basics.d
@@ -41,5 +41,11 @@ BEGIN
 	i = i ^ 5;
 	printf("The value of i is %d\n", i);
 
+	i = 0xdeadbeef; j = ~i; printf("~ %x is %x\n", i, j);
+	i = 0x0000beef; j = ~i; printf("~ %x is %x\n", i, j);
+
+	x = 0xdeadbeefdeadbeefull; y = ~x; printf("~ %x is %x\n", x, y);
+	x = 0x00000000deadbeefull; y = ~x; printf("~ %x is %x\n", x, y);
+
 	exit (0);
 }
diff --git a/test/unittest/arithmetic/tst.basics.r b/test/unittest/arithmetic/tst.basics.r
index d3b6af81..bd7690b5 100644
--- a/test/unittest/arithmetic/tst.basics.r
+++ b/test/unittest/arithmetic/tst.basics.r
@@ -5,4 +5,8 @@ The value of i is 25920
 The value of i is 935761216
 The value of i is -91738734
 The value of i is -91738729
+~ deadbeef is 21524110
+~ beef is ffff4110
+~ deadbeefdeadbeef is 2152411021524110
+~ deadbeef is ffffffff21524110
 
diff --git a/test/unittest/types/tst.assignops.d b/test/unittest/types/tst.assignops.d
index 44e3f3ec..18cbe45a 100644
--- a/test/unittest/types/tst.assignops.d
+++ b/test/unittest/types/tst.assignops.d
@@ -4,7 +4,6 @@
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
 
 /*
  * ASSERTION:
diff --git a/test/unittest/types/tst.unaryop.d b/test/unittest/types/tst.unaryop.d
index db592c15..6316fe37 100644
--- a/test/unittest/types/tst.unaryop.d
+++ b/test/unittest/types/tst.unaryop.d
@@ -4,7 +4,6 @@
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
 
 /*
  * ASSERTION:
-- 
2.18.4




More information about the DTrace-devel mailing list