diff options
author | Mike Frysinger <vapier@gentoo.org> | 2017-02-13 00:12:35 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2017-02-13 01:26:21 -0500 |
commit | 13a590ca65f744c8fa55d6e0748cb12f443493f0 (patch) | |
tree | 0aaec23ac3d6682a00d7af03dbef8e790c47b681 /sim/m68hc11 | |
parent | b1499fc214c2877ba76d7dffd4c41e33f3ec37f6 (diff) | |
download | gdb-13a590ca65f744c8fa55d6e0748cb12f443493f0.zip gdb-13a590ca65f744c8fa55d6e0748cb12f443493f0.tar.gz gdb-13a590ca65f744c8fa55d6e0748cb12f443493f0.tar.bz2 |
sim: use ARRAY_SIZE instead of ad-hoc sizeof calculations
Diffstat (limited to 'sim/m68hc11')
-rw-r--r-- | sim/m68hc11/ChangeLog | 9 | ||||
-rw-r--r-- | sim/m68hc11/gencode.c | 41 | ||||
-rw-r--r-- | sim/m68hc11/interrupts.c | 3 |
3 files changed, 30 insertions, 23 deletions
diff --git a/sim/m68hc11/ChangeLog b/sim/m68hc11/ChangeLog index bc69d84..8947c4b 100644 --- a/sim/m68hc11/ChangeLog +++ b/sim/m68hc11/ChangeLog @@ -1,3 +1,12 @@ +2017-02-13 Mike Frysinger <vapier@gentoo.org> + + * gencode.c: Include libiberty.h. + (TABLE_SIZE): Delete. + (find_opcode_pattern): Change TABLE_SIZE to ARRAY_SIZE. + (gen_interpreter): Likewise. + * interrupts.c (TableSize): Delete. + (interrupts_update_pending): Change TableSize to ARRAY_SIZE. + 2016-08-16 Mike Frysinger <vapier@gentoo.org> * sim-main.h (inline): Delete define. diff --git a/sim/m68hc11/gencode.c b/sim/m68hc11/gencode.c index e207606..3e85c93 100644 --- a/sim/m68hc11/gencode.c +++ b/sim/m68hc11/gencode.c @@ -24,10 +24,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <errno.h> #include "ansidecl.h" +#include "libiberty.h" #include "opcode/m68hc11.h" -#define TABLE_SIZE(X) (sizeof(X) / sizeof(X[0])) - /* Combination of CCR flags. */ #define M6811_ZC_BIT M6811_Z_BIT|M6811_C_BIT #define M6811_NZ_BIT M6811_N_BIT|M6811_Z_BIT @@ -1812,7 +1811,7 @@ find_opcode_pattern (const struct m6811_opcode_def *opcode) { pattern = opcode->name; } - for (i = 0; i < TABLE_SIZE(m6811_opcode_patterns); i++) + for (i = 0; i < ARRAY_SIZE (m6811_opcode_patterns); i++) { if (strcmp (m6811_opcode_patterns[i].name, pattern) == 0) { @@ -2036,13 +2035,13 @@ gen_interpreter (FILE *fp) { int col = 0; - prepare_table (m6811_page1_opcodes, TABLE_SIZE (m6811_page1_opcodes)); - prepare_table (m6811_page2_opcodes, TABLE_SIZE (m6811_page2_opcodes)); - prepare_table (m6811_page3_opcodes, TABLE_SIZE (m6811_page3_opcodes)); - prepare_table (m6811_page4_opcodes, TABLE_SIZE (m6811_page4_opcodes)); + prepare_table (m6811_page1_opcodes, ARRAY_SIZE (m6811_page1_opcodes)); + prepare_table (m6811_page2_opcodes, ARRAY_SIZE (m6811_page2_opcodes)); + prepare_table (m6811_page3_opcodes, ARRAY_SIZE (m6811_page3_opcodes)); + prepare_table (m6811_page4_opcodes, ARRAY_SIZE (m6811_page4_opcodes)); - prepare_table (m6812_page1_opcodes, TABLE_SIZE (m6812_page1_opcodes)); - prepare_table (m6812_page2_opcodes, TABLE_SIZE (m6812_page2_opcodes)); + prepare_table (m6812_page1_opcodes, ARRAY_SIZE (m6812_page1_opcodes)); + prepare_table (m6812_page2_opcodes, ARRAY_SIZE (m6812_page2_opcodes)); /* Generate header of interpretor. */ print (fp, col, "/* File generated automatically by gencode. */\n"); @@ -2051,25 +2050,25 @@ gen_interpreter (FILE *fp) if (cpu_type & cpu6811) { gen_cycle_table (fp, "cycles_page1", m6811_page1_opcodes, - TABLE_SIZE (m6811_page1_opcodes)); + ARRAY_SIZE (m6811_page1_opcodes)); gen_cycle_table (fp, "cycles_page2", m6811_page2_opcodes, - TABLE_SIZE (m6811_page2_opcodes)); + ARRAY_SIZE (m6811_page2_opcodes)); gen_cycle_table (fp, "cycles_page3", m6811_page3_opcodes, - TABLE_SIZE (m6811_page3_opcodes)); + ARRAY_SIZE (m6811_page3_opcodes)); gen_cycle_table (fp, "cycles_page4", m6811_page4_opcodes, - TABLE_SIZE (m6811_page4_opcodes)); + ARRAY_SIZE (m6811_page4_opcodes)); gen_function_entry (fp, "static void\ncpu_page3_interp", 0); gen_interpreter_for_table (fp, indent_level, m6811_page3_opcodes, - TABLE_SIZE(m6811_page3_opcodes), + ARRAY_SIZE (m6811_page3_opcodes), "cycles_page3"); gen_function_close (fp); gen_function_entry (fp, "static void\ncpu_page4_interp", 0); gen_interpreter_for_table (fp, indent_level, m6811_page4_opcodes, - TABLE_SIZE(m6811_page4_opcodes), + ARRAY_SIZE (m6811_page4_opcodes), "cycles_page4"); gen_function_close (fp); @@ -2078,7 +2077,7 @@ gen_interpreter (FILE *fp) USE_SRC8 | USE_DST8); gen_interpreter_for_table (fp, indent_level, m6811_page2_opcodes, - TABLE_SIZE(m6811_page2_opcodes), + ARRAY_SIZE (m6811_page2_opcodes), "cycles_page2"); gen_function_close (fp); @@ -2087,22 +2086,22 @@ gen_interpreter (FILE *fp) USE_SRC8 | USE_DST8); gen_interpreter_for_table (fp, indent_level, m6811_page1_opcodes, - TABLE_SIZE(m6811_page1_opcodes), + ARRAY_SIZE (m6811_page1_opcodes), "cycles_page1"); gen_function_close (fp); } else { gen_cycle_table (fp, "cycles_page1", m6812_page1_opcodes, - TABLE_SIZE (m6812_page1_opcodes)); + ARRAY_SIZE (m6812_page1_opcodes)); gen_cycle_table (fp, "cycles_page2", m6812_page2_opcodes, - TABLE_SIZE (m6812_page2_opcodes)); + ARRAY_SIZE (m6812_page2_opcodes)); gen_function_entry (fp, "static void\ncpu_page2_interp", USE_SRC8 | USE_DST8); gen_interpreter_for_table (fp, indent_level, m6812_page2_opcodes, - TABLE_SIZE(m6812_page2_opcodes), + ARRAY_SIZE (m6812_page2_opcodes), "cycles_page2"); gen_function_close (fp); @@ -2111,7 +2110,7 @@ gen_interpreter (FILE *fp) USE_SRC8 | USE_DST8); gen_interpreter_for_table (fp, indent_level, m6812_page1_opcodes, - TABLE_SIZE(m6812_page1_opcodes), + ARRAY_SIZE (m6812_page1_opcodes), "cycles_page1"); gen_function_close (fp); } diff --git a/sim/m68hc11/interrupts.c b/sim/m68hc11/interrupts.c index 129f3c0..ed82655 100644 --- a/sim/m68hc11/interrupts.c +++ b/sim/m68hc11/interrupts.c @@ -91,7 +91,6 @@ struct interrupt_def idefs[] = { #endif }; -#define TableSize(X) (sizeof X / sizeof(X[0])) #define CYCLES_MAX ((((signed64) 1) << 62) - 1) enum @@ -290,7 +289,7 @@ interrupts_update_pending (struct interrupts *interrupts) set_mask = 0; ioregs = &interrupts->cpu->ios[0]; - for (i = 0; i < TableSize(idefs); i++) + for (i = 0; i < ARRAY_SIZE (idefs); i++) { struct interrupt_def *idef = &idefs[i]; uint8 data; |