This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 2/4] gdb/riscv: Add equality operators to riscv_gdb_features
- From: Andrew Burgess <andrew dot burgess at embecosm dot com>
- To: gdb-patches at sourceware dot org
- Cc: jimw at sifive dot com, palmer at sifive dot com, jhb at FreeBSD dot org, Andrew Burgess <andrew dot burgess at embecosm dot com>
- Date: Thu, 29 Nov 2018 16:48:11 +0000
- Subject: [PATCH 2/4] gdb/riscv: Add equality operators to riscv_gdb_features
- References: <cover.1543509416.git.andrew.burgess@embecosm.com>
- References: <CAFyWVabMg7KYrE64GBz2qLcNJob=zOJLjWg0cFz1De-mRFoM+A@mail.gmail.com> <cover.1543509416.git.andrew.burgess@embecosm.com>
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.
---
gdb/ChangeLog | 7 +++++++
gdb/arch/riscv.h | 13 +++++++++++++
gdb/riscv-tdep.c | 4 +---
3 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/gdb/arch/riscv.h b/gdb/arch/riscv.h
index ec4d5f39525..be41828eff6 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 d66fe5c8793..30c777db6f2 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;
--
2.14.5