This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] gdb/riscv: Add equality operators to riscv_gdb_features
- From: Andrew Burgess <aburgess at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 30 Nov 2018 18:22:14 -0000
- Subject: [binutils-gdb] gdb/riscv: Add equality operators to riscv_gdb_features
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=65a4b373267813ae5e47ac519da2e70d9c7e09d3
commit 65a4b373267813ae5e47ac519da2e70d9c7e09d3
Author: Andrew Burgess <andrew.burgess@embecosm.com>
Date: Thu Nov 29 15:07:59 2018 +0000
gdb/riscv: Add equality operators to riscv_gdb_features
Add '==' and '!=' operators for the struct riscv_gdb_features,
allowing a small simplification.
gdb/ChangeLog:
* arch/riscv.h (riscv_gdb_features::operator==): New.
(riscv_gdb_features::operator!=): New.
* riscv-tdep.c (riscv_gdbarch_init): Make use of the inequality
operator.
Diff:
---
gdb/ChangeLog | 7 +++++++
gdb/arch/riscv.h | 13 +++++++++++++
gdb/riscv-tdep.c | 4 +---
3 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 72c2ee1..306e1a1 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
2018-11-30 Andrew Burgess <andrew.burgess@embecosm.com>
+ * arch/riscv.h (riscv_gdb_features::operator==): New.
+ (riscv_gdb_features::operator!=): New.
+ * riscv-tdep.c (riscv_gdbarch_init): Make use of the inequality
+ operator.
+
+2018-11-30 Andrew Burgess <andrew.burgess@embecosm.com>
+
* arch/riscv.h (riscv_create_target_description): Make return type
const.
* arch/riscv.c (riscv_create_target_description): Likewise.
diff --git a/gdb/arch/riscv.h b/gdb/arch/riscv.h
index ec4d5f3..be41828e 100644
--- a/gdb/arch/riscv.h
+++ b/gdb/arch/riscv.h
@@ -53,6 +53,19 @@ struct riscv_gdbarch_features
this field is true then the hardware floating point abi is in use, and
values are passed in f-registers matching the size of FLEN. */
bool hw_float_abi = false;
+
+ /* Equality operator. */
+ bool operator== (const struct riscv_gdbarch_features &rhs) const
+ {
+ return (xlen == rhs.xlen && flen == rhs.flen
+ && hw_float_abi == rhs.hw_float_abi);
+ }
+
+ /* Inequality operator. */
+ bool operator!= (const struct riscv_gdbarch_features &rhs) const
+ {
+ return !((*this) == rhs);
+ }
};
/* Create and return a target description that is compatible with
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index d66fe5c..30c777d 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -3025,9 +3025,7 @@ riscv_gdbarch_init (struct gdbarch_info info,
gdbarch. */
struct gdbarch_tdep *other_tdep = gdbarch_tdep (arches->gdbarch);
- if (other_tdep->features.hw_float_abi != features.hw_float_abi
- || other_tdep->features.xlen != features.xlen
- || other_tdep->features.flen != features.flen)
+ if (other_tdep->features != features)
continue;
break;