• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revision13a590ca65f744c8fa55d6e0748cb12f443493f0 (tree)
Zeit2017-02-13 15:26:21
AutorMike Frysinger <vapier@gent...>
CommiterMike Frysinger

Log Message

sim: use ARRAY_SIZE instead of ad-hoc sizeof calculations

Ändern Zusammenfassung

Diff

--- a/sim/arm/ChangeLog
+++ b/sim/arm/ChangeLog
@@ -1,3 +1,11 @@
1+2017-02-13 Mike Frysinger <vapier@gentoo.org>
2+
3+ * armos.c: Include libiberty.h.
4+ (SWIopen): Use ARRAY_SIZE.
5+ * armsupp.c: Include libiberty.h.
6+ (ModeToBank): Use ARRAY_SIZE.
7+ * wrapper.c (sim_target_parse_command_line): Likewise.
8+
19 2016-07-14 Nick Clifton <nickc@redhat.com>
210
311 * armemu.c (Multiply64): Only issue error messages about invalid
--- a/sim/arm/armos.c
+++ b/sim/arm/armos.c
@@ -23,6 +23,7 @@
2323
2424 #include "config.h"
2525 #include "ansidecl.h"
26+#include "libiberty.h"
2627
2728 #include <time.h>
2829 #include <errno.h>
@@ -260,7 +261,7 @@ SWIopen (ARMul_State * state, ARMword name, ARMword SWIflags)
260261 return;
261262
262263 /* Now we need to decode the Demon open mode. */
263- if (SWIflags >= sizeof (translate_open_mode) / sizeof (translate_open_mode[0]))
264+ if (SWIflags >= ARRAY_SIZE (translate_open_mode))
264265 flags = 0;
265266 else
266267 flags = translate_open_mode[SWIflags];
--- a/sim/arm/armsupp.c
+++ b/sim/arm/armsupp.c
@@ -17,6 +17,7 @@
1717 #include "armdefs.h"
1818 #include "armemu.h"
1919 #include "ansidecl.h"
20+#include "libiberty.h"
2021 #include <math.h>
2122
2223 /* Definitions for the support routines. */
@@ -373,7 +374,7 @@ ModeToBank (ARMword mode)
373374 DUMMYBANK, DUMMYBANK, DUMMYBANK, SYSTEMBANK
374375 };
375376
376- if (mode >= (sizeof (bankofmode) / sizeof (bankofmode[0])))
377+ if (mode >= ARRAY_SIZE (bankofmode))
377378 return DUMMYBANK;
378379
379380 return bankofmode[mode];
--- a/sim/arm/wrapper.c
+++ b/sim/arm/wrapper.c
@@ -740,7 +740,7 @@ sim_target_parse_command_line (int argc, char ** argv)
740740 {
741741 int i;
742742
743- for (i = sizeof options / sizeof options[0]; i--;)
743+ for (i = ARRAY_SIZE (options); i--;)
744744 if (strncmp (ptr, options[i].swi_option,
745745 strlen (options[i].swi_option)) == 0)
746746 {
--- a/sim/cris/ChangeLog
+++ b/sim/cris/ChangeLog
@@ -1,3 +1,9 @@
1+2017-02-13 Mike Frysinger <vapier@gentoo.org>
2+
3+ * decodev10.c (crisv10f_init_idesc_table): Use ARRAY_SIZE.
4+ * decodev32.c (crisv32f_init_idesc_table): Likewise.
5+ * sim-if.c (sim_open): Likewise.
6+
17 2016-01-10 Mike Frysinger <vapier@gentoo.org>
28
39 * config.in, configure: Regenerate.
--- a/sim/cris/decodev10.c
+++ b/sim/cris/decodev10.c
@@ -302,7 +302,7 @@ crisv10f_init_idesc_table (SIM_CPU *cpu)
302302 init_idesc (cpu, id, t);
303303
304304 /* Now fill in the values for the chosen cpu. */
305- for (t = crisv10f_insn_sem, tend = t + sizeof (crisv10f_insn_sem) / sizeof (*t);
305+ for (t = crisv10f_insn_sem, tend = t + ARRAY_SIZE (crisv10f_insn_sem);
306306 t != tend; ++t)
307307 {
308308 init_idesc (cpu, & table[t->index], t);
--- a/sim/cris/decodev32.c
+++ b/sim/cris/decodev32.c
@@ -306,7 +306,7 @@ crisv32f_init_idesc_table (SIM_CPU *cpu)
306306 init_idesc (cpu, id, t);
307307
308308 /* Now fill in the values for the chosen cpu. */
309- for (t = crisv32f_insn_sem, tend = t + sizeof (crisv32f_insn_sem) / sizeof (*t);
309+ for (t = crisv32f_insn_sem, tend = t + ARRAY_SIZE (crisv32f_insn_sem);
310310 t != tend; ++t)
311311 {
312312 init_idesc (cpu, & table[t->index], t);
--- a/sim/cris/sim-if.c
+++ b/sim/cris/sim-if.c
@@ -786,7 +786,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
786786 /* Note that the linux kernel does not correctly compute the storage
787787 needs for the static-exe AUX vector. */
788788
789- csp -= sizeof (auxv_entries) / sizeof (auxv_entries[0]) * 4 * 2;
789+ csp -= ARRAY_SIZE (auxv_entries) * 4 * 2;
790790
791791 csp -= (envc + 1) * 4;
792792 csp -= (my_argc + 1) * 4;
@@ -874,7 +874,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
874874 goto abandon_chip;
875875
876876 if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
877- for (i = 0; i < sizeof (auxv_entries) / sizeof (auxv_entries[0]); i++)
877+ for (i = 0; i < ARRAY_SIZE (auxv_entries); i++)
878878 {
879879 write_dword (csp, auxv_entries[i].id);
880880 write_dword (csp + 4,
--- a/sim/frv/ChangeLog
+++ b/sim/frv/ChangeLog
@@ -1,3 +1,7 @@
1+2017-02-13 Mike Frysinger <vapier@gentoo.org>
2+
3+ * decode.c (frvbf_init_idesc_table): Use ARRAY_SIZE.
4+
15 2016-01-10 Mike Frysinger <vapier@gentoo.org>
26
37 * config.in, configure: Regenerate.
--- a/sim/frv/decode.c
+++ b/sim/frv/decode.c
@@ -841,7 +841,7 @@ frvbf_init_idesc_table (SIM_CPU *cpu)
841841 init_idesc (cpu, id, t);
842842
843843 /* Now fill in the values for the chosen cpu. */
844- for (t = frvbf_insn_sem, tend = t + sizeof (frvbf_insn_sem) / sizeof (*t);
844+ for (t = frvbf_insn_sem, tend = t + ARRAY_SIZE (frvbf_insn_sem);
845845 t != tend; ++t)
846846 {
847847 init_idesc (cpu, & table[t->index], t);
--- a/sim/iq2000/ChangeLog
+++ b/sim/iq2000/ChangeLog
@@ -1,3 +1,7 @@
1+2017-02-13 Mike Frysinger <vapier@gentoo.org>
2+
3+ * decode.c (iq2000bf_init_idesc_table): Use ARRAY_SIZE.
4+
15 2016-01-10 Mike Frysinger <vapier@gentoo.org>
26
37 * config.in, configure: Regenerate.
--- a/sim/iq2000/decode.c
+++ b/sim/iq2000/decode.c
@@ -242,7 +242,7 @@ iq2000bf_init_idesc_table (SIM_CPU *cpu)
242242 init_idesc (cpu, id, t);
243243
244244 /* Now fill in the values for the chosen cpu. */
245- for (t = iq2000bf_insn_sem, tend = t + sizeof (iq2000bf_insn_sem) / sizeof (*t);
245+ for (t = iq2000bf_insn_sem, tend = t + ARRAY_SIZE (iq2000bf_insn_sem);
246246 t != tend; ++t)
247247 {
248248 init_idesc (cpu, & table[t->index], t);
--- a/sim/lm32/ChangeLog
+++ b/sim/lm32/ChangeLog
@@ -1,3 +1,7 @@
1+2017-02-13 Mike Frysinger <vapier@gentoo.org>
2+
3+ * decode.c (lm32bf_init_idesc_table): Use ARRAY_SIZE.
4+
15 2016-08-15 Mike Frysinger <vapier@gentoo.org>
26
37 * sim-if.c (find_limit): Change prototype to take a SIM_DESC.
--- a/sim/lm32/decode.c
+++ b/sim/lm32/decode.c
@@ -160,7 +160,7 @@ lm32bf_init_idesc_table (SIM_CPU *cpu)
160160 init_idesc (cpu, id, t);
161161
162162 /* Now fill in the values for the chosen cpu. */
163- for (t = lm32bf_insn_sem, tend = t + sizeof (lm32bf_insn_sem) / sizeof (*t);
163+ for (t = lm32bf_insn_sem, tend = t + ARRAY_SIZE (lm32bf_insn_sem);
164164 t != tend; ++t)
165165 {
166166 init_idesc (cpu, & table[t->index], t);
--- a/sim/m32c/ChangeLog
+++ b/sim/m32c/ChangeLog
@@ -1,3 +1,8 @@
1+2017-02-13 Mike Frysinger <vapier@gentoo.org>
2+
3+ * srcdest.c: Include libiberty.h.
4+ (decode_sd23): Use ARRAY_SIZE.
5+
16 2016-01-10 Mike Frysinger <vapier@gentoo.org>
27
38 * config.in, configure: Regenerate.
--- a/sim/m32c/srcdest.c
+++ b/sim/m32c/srcdest.c
@@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
2222 #include <stdio.h>
2323 #include <stdlib.h>
2424
25+#include "libiberty.h"
2526 #include "cpu.h"
2627 #include "mem.h"
2728
@@ -354,7 +355,7 @@ decode_sd23 (int bbb, int bb, int bytes, int ind, int add)
354355 srcdest sd;
355356 int code = (bbb << 2) | bb;
356357
357- if (code >= sizeof (modes23) / sizeof (modes23[0]))
358+ if (code >= ARRAY_SIZE (modes23))
358359 abort ();
359360
360361 if (trace)
--- a/sim/m32r/ChangeLog
+++ b/sim/m32r/ChangeLog
@@ -1,3 +1,9 @@
1+2017-02-13 Mike Frysinger <vapier@gentoo.org>
2+
3+ * decode.c (m32rbf_init_idesc_table): Use ARRAY_SIZE.
4+ * decode2.c (m32r2f_init_idesc_table): Likewise.
5+ * decodex.c (m32rxf_init_idesc_table): Likewise.
6+
17 2016-01-10 Mike Frysinger <vapier@gentoo.org>
28
39 * config.in, configure: Regenerate.
--- a/sim/m32r/decode.c
+++ b/sim/m32r/decode.c
@@ -202,7 +202,7 @@ m32rbf_init_idesc_table (SIM_CPU *cpu)
202202 init_idesc (cpu, id, t);
203203
204204 /* Now fill in the values for the chosen cpu. */
205- for (t = m32rbf_insn_sem, tend = t + sizeof (m32rbf_insn_sem) / sizeof (*t);
205+ for (t = m32rbf_insn_sem, tend = t + ARRAY_SIZE (m32rbf_insn_sem);
206206 t != tend; ++t)
207207 {
208208 init_idesc (cpu, & table[t->index], t);
--- a/sim/m32r/decode2.c
+++ b/sim/m32r/decode2.c
@@ -235,7 +235,7 @@ m32r2f_init_idesc_table (SIM_CPU *cpu)
235235 init_idesc (cpu, id, t);
236236
237237 /* Now fill in the values for the chosen cpu. */
238- for (t = m32r2f_insn_sem, tend = t + sizeof (m32r2f_insn_sem) / sizeof (*t);
238+ for (t = m32r2f_insn_sem, tend = t + ARRAY_SIZE (m32r2f_insn_sem);
239239 t != tend; ++t)
240240 {
241241 init_idesc (cpu, & table[t->index], t);
--- a/sim/m32r/decodex.c
+++ b/sim/m32r/decodex.c
@@ -228,7 +228,7 @@ m32rxf_init_idesc_table (SIM_CPU *cpu)
228228 init_idesc (cpu, id, t);
229229
230230 /* Now fill in the values for the chosen cpu. */
231- for (t = m32rxf_insn_sem, tend = t + sizeof (m32rxf_insn_sem) / sizeof (*t);
231+ for (t = m32rxf_insn_sem, tend = t + ARRAY_SIZE (m32rxf_insn_sem);
232232 t != tend; ++t)
233233 {
234234 init_idesc (cpu, & table[t->index], t);
--- a/sim/m68hc11/ChangeLog
+++ b/sim/m68hc11/ChangeLog
@@ -1,3 +1,12 @@
1+2017-02-13 Mike Frysinger <vapier@gentoo.org>
2+
3+ * gencode.c: Include libiberty.h.
4+ (TABLE_SIZE): Delete.
5+ (find_opcode_pattern): Change TABLE_SIZE to ARRAY_SIZE.
6+ (gen_interpreter): Likewise.
7+ * interrupts.c (TableSize): Delete.
8+ (interrupts_update_pending): Change TableSize to ARRAY_SIZE.
9+
110 2016-08-16 Mike Frysinger <vapier@gentoo.org>
211
312 * sim-main.h (inline): Delete define.
--- 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/>. */
2424 #include <errno.h>
2525
2626 #include "ansidecl.h"
27+#include "libiberty.h"
2728 #include "opcode/m68hc11.h"
2829
29-#define TABLE_SIZE(X) (sizeof(X) / sizeof(X[0]))
30-
3130 /* Combination of CCR flags. */
3231 #define M6811_ZC_BIT M6811_Z_BIT|M6811_C_BIT
3332 #define M6811_NZ_BIT M6811_N_BIT|M6811_Z_BIT
@@ -1812,7 +1811,7 @@ find_opcode_pattern (const struct m6811_opcode_def *opcode)
18121811 {
18131812 pattern = opcode->name;
18141813 }
1815- for (i = 0; i < TABLE_SIZE(m6811_opcode_patterns); i++)
1814+ for (i = 0; i < ARRAY_SIZE (m6811_opcode_patterns); i++)
18161815 {
18171816 if (strcmp (m6811_opcode_patterns[i].name, pattern) == 0)
18181817 {
@@ -2036,13 +2035,13 @@ gen_interpreter (FILE *fp)
20362035 {
20372036 int col = 0;
20382037
2039- prepare_table (m6811_page1_opcodes, TABLE_SIZE (m6811_page1_opcodes));
2040- prepare_table (m6811_page2_opcodes, TABLE_SIZE (m6811_page2_opcodes));
2041- prepare_table (m6811_page3_opcodes, TABLE_SIZE (m6811_page3_opcodes));
2042- prepare_table (m6811_page4_opcodes, TABLE_SIZE (m6811_page4_opcodes));
2038+ prepare_table (m6811_page1_opcodes, ARRAY_SIZE (m6811_page1_opcodes));
2039+ prepare_table (m6811_page2_opcodes, ARRAY_SIZE (m6811_page2_opcodes));
2040+ prepare_table (m6811_page3_opcodes, ARRAY_SIZE (m6811_page3_opcodes));
2041+ prepare_table (m6811_page4_opcodes, ARRAY_SIZE (m6811_page4_opcodes));
20432042
2044- prepare_table (m6812_page1_opcodes, TABLE_SIZE (m6812_page1_opcodes));
2045- prepare_table (m6812_page2_opcodes, TABLE_SIZE (m6812_page2_opcodes));
2043+ prepare_table (m6812_page1_opcodes, ARRAY_SIZE (m6812_page1_opcodes));
2044+ prepare_table (m6812_page2_opcodes, ARRAY_SIZE (m6812_page2_opcodes));
20462045
20472046 /* Generate header of interpretor. */
20482047 print (fp, col, "/* File generated automatically by gencode. */\n");
@@ -2051,25 +2050,25 @@ gen_interpreter (FILE *fp)
20512050 if (cpu_type & cpu6811)
20522051 {
20532052 gen_cycle_table (fp, "cycles_page1", m6811_page1_opcodes,
2054- TABLE_SIZE (m6811_page1_opcodes));
2053+ ARRAY_SIZE (m6811_page1_opcodes));
20552054 gen_cycle_table (fp, "cycles_page2", m6811_page2_opcodes,
2056- TABLE_SIZE (m6811_page2_opcodes));
2055+ ARRAY_SIZE (m6811_page2_opcodes));
20572056 gen_cycle_table (fp, "cycles_page3", m6811_page3_opcodes,
2058- TABLE_SIZE (m6811_page3_opcodes));
2057+ ARRAY_SIZE (m6811_page3_opcodes));
20592058 gen_cycle_table (fp, "cycles_page4", m6811_page4_opcodes,
2060- TABLE_SIZE (m6811_page4_opcodes));
2059+ ARRAY_SIZE (m6811_page4_opcodes));
20612060
20622061 gen_function_entry (fp, "static void\ncpu_page3_interp", 0);
20632062 gen_interpreter_for_table (fp, indent_level,
20642063 m6811_page3_opcodes,
2065- TABLE_SIZE(m6811_page3_opcodes),
2064+ ARRAY_SIZE (m6811_page3_opcodes),
20662065 "cycles_page3");
20672066 gen_function_close (fp);
20682067
20692068 gen_function_entry (fp, "static void\ncpu_page4_interp", 0);
20702069 gen_interpreter_for_table (fp, indent_level,
20712070 m6811_page4_opcodes,
2072- TABLE_SIZE(m6811_page4_opcodes),
2071+ ARRAY_SIZE (m6811_page4_opcodes),
20732072 "cycles_page4");
20742073 gen_function_close (fp);
20752074
@@ -2078,7 +2077,7 @@ gen_interpreter (FILE *fp)
20782077 USE_SRC8 | USE_DST8);
20792078 gen_interpreter_for_table (fp, indent_level,
20802079 m6811_page2_opcodes,
2081- TABLE_SIZE(m6811_page2_opcodes),
2080+ ARRAY_SIZE (m6811_page2_opcodes),
20822081 "cycles_page2");
20832082 gen_function_close (fp);
20842083
@@ -2087,22 +2086,22 @@ gen_interpreter (FILE *fp)
20872086 USE_SRC8 | USE_DST8);
20882087
20892088 gen_interpreter_for_table (fp, indent_level, m6811_page1_opcodes,
2090- TABLE_SIZE(m6811_page1_opcodes),
2089+ ARRAY_SIZE (m6811_page1_opcodes),
20912090 "cycles_page1");
20922091 gen_function_close (fp);
20932092 }
20942093 else
20952094 {
20962095 gen_cycle_table (fp, "cycles_page1", m6812_page1_opcodes,
2097- TABLE_SIZE (m6812_page1_opcodes));
2096+ ARRAY_SIZE (m6812_page1_opcodes));
20982097 gen_cycle_table (fp, "cycles_page2", m6812_page2_opcodes,
2099- TABLE_SIZE (m6812_page2_opcodes));
2098+ ARRAY_SIZE (m6812_page2_opcodes));
21002099
21012100 gen_function_entry (fp, "static void\ncpu_page2_interp",
21022101 USE_SRC8 | USE_DST8);
21032102 gen_interpreter_for_table (fp, indent_level,
21042103 m6812_page2_opcodes,
2105- TABLE_SIZE(m6812_page2_opcodes),
2104+ ARRAY_SIZE (m6812_page2_opcodes),
21062105 "cycles_page2");
21072106 gen_function_close (fp);
21082107
@@ -2111,7 +2110,7 @@ gen_interpreter (FILE *fp)
21112110 USE_SRC8 | USE_DST8);
21122111
21132112 gen_interpreter_for_table (fp, indent_level, m6812_page1_opcodes,
2114- TABLE_SIZE(m6812_page1_opcodes),
2113+ ARRAY_SIZE (m6812_page1_opcodes),
21152114 "cycles_page1");
21162115 gen_function_close (fp);
21172116 }
--- a/sim/m68hc11/interrupts.c
+++ b/sim/m68hc11/interrupts.c
@@ -91,7 +91,6 @@ struct interrupt_def idefs[] = {
9191 #endif
9292 };
9393
94-#define TableSize(X) (sizeof X / sizeof(X[0]))
9594 #define CYCLES_MAX ((((signed64) 1) << 62) - 1)
9695
9796 enum
@@ -290,7 +289,7 @@ interrupts_update_pending (struct interrupts *interrupts)
290289 set_mask = 0;
291290 ioregs = &interrupts->cpu->ios[0];
292291
293- for (i = 0; i < TableSize(idefs); i++)
292+ for (i = 0; i < ARRAY_SIZE (idefs); i++)
294293 {
295294 struct interrupt_def *idef = &idefs[i];
296295 uint8 data;
--- a/sim/ppc/ChangeLog
+++ b/sim/ppc/ChangeLog
@@ -1,3 +1,15 @@
1+2017-02-13 Mike Frysinger <vapier@gentoo.org>
2+
3+ * cpu.h: Include libiberty.h.
4+ * emul_bugapi.c (emul_bugapi_instruction_name): Use ARRAY_SIZE.
5+ * emul_generic.h: Include libiberty.h.
6+ * emul_netbsd.c (emul_netbsd_syscalls): Use ARRAY_SIZE.
7+ * emul_unix.c (convert_to_solaris_stat): Likewise.
8+ (emul_solaris_syscalls): Likewise.
9+ (emul_linux_syscalls): Likewise.
10+ * options.c (print_options): Likewise.
11+ * ppc-instructions: Likewise.
12+
113 2016-01-10 Mike Frysinger <vapier@gentoo.org>
214
315 * configure.ac (sim-assert): Call AC_MSG_CHECKING,
--- a/sim/ppc/cpu.h
+++ b/sim/ppc/cpu.h
@@ -34,6 +34,7 @@
3434 #include "os_emul.h"
3535 #include "mon.h"
3636 #include "model.h"
37+#include "libiberty.h"
3738
3839 #ifndef CONST_ATTRIBUTE
3940 #define CONST_ATTRIBUTE __attribute__((__const__))
--- a/sim/ppc/emul_bugapi.c
+++ b/sim/ppc/emul_bugapi.c
@@ -339,7 +339,7 @@ emul_bugapi_instruction_name(int call_id)
339339 static char buffer[40];
340340 int i;
341341
342- for (i = 0; i < sizeof (bug_mapping) / sizeof (bug_mapping[0]); i++)
342+ for (i = 0; i < ARRAY_SIZE (bug_mapping); i++)
343343 {
344344 if (bug_mapping[i].value == call_id)
345345 return bug_mapping[i].info;
--- a/sim/ppc/emul_generic.h
+++ b/sim/ppc/emul_generic.h
@@ -28,6 +28,7 @@
2828 #include "tree.h"
2929
3030 #include "bfd.h"
31+#include "libiberty.h"
3132
3233 #ifndef INLINE_EMUL_GENERIC
3334 #define INLINE_EMUL_GENERIC
--- a/sim/ppc/emul_netbsd.c
+++ b/sim/ppc/emul_netbsd.c
@@ -1413,11 +1413,11 @@ static char *(netbsd_signal_names[]) = {
14131413
14141414 static emul_syscall emul_netbsd_syscalls = {
14151415 netbsd_descriptors,
1416- sizeof(netbsd_descriptors) / sizeof(netbsd_descriptors[0]),
1416+ ARRAY_SIZE (netbsd_descriptors),
14171417 netbsd_error_names,
1418- sizeof(netbsd_error_names) / sizeof(netbsd_error_names[0]),
1418+ ARRAY_SIZE (netbsd_error_names),
14191419 netbsd_signal_names,
1420- sizeof(netbsd_signal_names) / sizeof(netbsd_signal_names[0]),
1420+ ARRAY_SIZE (netbsd_signal_names),
14211421 };
14221422
14231423
--- a/sim/ppc/emul_unix.c
+++ b/sim/ppc/emul_unix.c
@@ -1147,15 +1147,15 @@ convert_to_solaris_stat(unsigned_word addr,
11471147 target.st_mtim.tv_sec = H2T_4(host->st_mtime);
11481148 target.st_mtim.tv_usec = 0;
11491149
1150- for (i = 0; i < sizeof (target.st_pad1) / sizeof (target.st_pad1[0]); i++)
1150+ for (i = 0; i < ARRAY_SIZE (target.st_pad1); i++)
11511151 target.st_pad1[i] = 0;
11521152
1153- for (i = 0; i < sizeof (target.st_pad2) / sizeof (target.st_pad2[0]); i++)
1153+ for (i = 0; i < ARRAY_SIZE (target.st_pad2); i++)
11541154 target.st_pad2[i] = 0;
11551155
11561156 target.st_pad3 = 0;
11571157
1158- for (i = 0; i < sizeof (target.st_pad4) / sizeof (target.st_pad4[0]); i++)
1158+ for (i = 0; i < ARRAY_SIZE (target.st_pad4); i++)
11591159 target.st_pad4[i] = 0;
11601160
11611161 /* For now, just punt and always say it is a ufs file */
@@ -1945,11 +1945,11 @@ static char *(solaris_signal_names[]) = {
19451945
19461946 static emul_syscall emul_solaris_syscalls = {
19471947 solaris_descriptors,
1948- sizeof(solaris_descriptors) / sizeof(solaris_descriptors[0]),
1948+ ARRAY_SIZE (solaris_descriptors),
19491949 solaris_error_names,
1950- sizeof(solaris_error_names) / sizeof(solaris_error_names[0]),
1950+ ARRAY_SIZE (solaris_error_names),
19511951 solaris_signal_names,
1952- sizeof(solaris_signal_names) / sizeof(solaris_signal_names[0]),
1952+ ARRAY_SIZE (solaris_signal_names),
19531953 };
19541954
19551955
@@ -2824,11 +2824,11 @@ static char *(linux_signal_names[]) = {
28242824
28252825 static emul_syscall emul_linux_syscalls = {
28262826 linux_descriptors,
2827- sizeof(linux_descriptors) / sizeof(linux_descriptors[0]),
2827+ ARRAY_SIZE (linux_descriptors),
28282828 linux_error_names,
2829- sizeof(linux_error_names) / sizeof(linux_error_names[0]),
2829+ ARRAY_SIZE (linux_error_names),
28302830 linux_signal_names,
2831- sizeof(linux_signal_names) / sizeof(linux_signal_names[0]),
2831+ ARRAY_SIZE (linux_signal_names),
28322832 };
28332833
28342834
--- a/sim/ppc/options.c
+++ b/sim/ppc/options.c
@@ -216,7 +216,7 @@ print_options (void)
216216 int max_len = 0;
217217 int cols;
218218
219- for (i = 0; i < sizeof (defines) / sizeof (defines[0]); i++) {
219+ for (i = 0; i < ARRAY_SIZE (defines); i++) {
220220 int len = strlen (defines[i]);
221221 if (len > max_len)
222222 max_len = len;
@@ -227,10 +227,10 @@ print_options (void)
227227 cols = 1;
228228
229229 printf_filtered ("\n#defines:");
230- for (i = 0; i < sizeof (defines) / sizeof (defines[0]); i++) {
230+ for (i = 0; i < ARRAY_SIZE (defines); i++) {
231231 const char *const prefix = ((i % cols) == 0) ? "\n" : "";
232232 printf_filtered ("%s %s%*s", prefix, defines[i],
233- (((i == (sizeof (defines) / sizeof (defines[0])) - 1)
233+ (((i == ARRAY_SIZE (defines) - 1)
234234 || (((i + 1) % cols) == 0))
235235 ? 0
236236 : max_len + 4 - strlen (defines[i])),
--- a/sim/ppc/ppc-instructions
+++ b/sim/ppc/ppc-instructions
@@ -908,7 +908,7 @@ model_print *::model-function::model_mon_info:model_data *model_ptr
908908 tail->suffix_singular = "";
909909 }
910910
911- for (j = 0; j < (sizeof(ppc_branch_conditional_name) / sizeof(ppc_branch_conditional_name[0])) ; j++) {
911+ for (j = 0; j < ARRAY_SIZE (ppc_branch_conditional_name); j++) {
912912 if (model_ptr->nr_branch_conditional[j]) {
913913 tail->next = ZALLOC(model_print);
914914 tail = tail->next;
--- a/sim/rx/ChangeLog
+++ b/sim/rx/ChangeLog
@@ -1,3 +1,8 @@
1+2017-02-13 Mike Frysinger <vapier@gentoo.org>
2+
3+ * rx.c: Include libiberty.h.
4+ (N_RXO, N_RXT): Use ARRAY_SIZE.
5+
16 2016-07-27 Alan Modra <amodra@gmail.com>
27
38 * load.c: Don't include libbfd.h.
--- a/sim/rx/rx.c
+++ b/sim/rx/rx.c
@@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
2323 #include <stdlib.h>
2424 #include <string.h>
2525 #include <signal.h>
26+#include "libiberty.h"
2627
2728 #include "opcode/rx.h"
2829 #include "cpu.h"
@@ -151,8 +152,8 @@ static const char * optype_names[] = {
151152 "RbRi" /* [Rb + scale * Ri] */
152153 };
153154
154-#define N_RXO (sizeof(id_names)/sizeof(id_names[0]))
155-#define N_RXT (sizeof(optype_names)/sizeof(optype_names[0]))
155+#define N_RXO ARRAY_SIZE (id_names)
156+#define N_RXT ARRAY_SIZE (optype_names)
156157 #define N_MAP 90
157158
158159 static unsigned long long benchmark_start_cycle;
--- a/sim/sh/ChangeLog
+++ b/sim/sh/ChangeLog
@@ -1,3 +1,9 @@
1+2017-02-13 Mike Frysinger <vapier@gentoo.org>
2+
3+ * gencode.c: Include libiberty.h.
4+ (conflict_warn): Use ARRAY_SIZE.
5+ * interp.c (init_dsp): Likewise.
6+
17 2016-04-10 Oleg Endo <olegendo@gcc.gnu.org>
28
39 * interp.c (dmul): Split into dmul_s and dmul_u. Use explicit integer
--- a/sim/sh/gencode.c
+++ b/sim/sh/gencode.c
@@ -35,6 +35,7 @@
3535 #include <stdlib.h>
3636 #include <string.h>
3737 #include <unistd.h>
38+#include "libiberty.h"
3839
3940 #define MAX_NR_STUFF 42
4041
@@ -2595,7 +2596,7 @@ conflict_warn (int val, int i)
25952596 fprintf (stderr, "Warning: opcode table conflict: 0x%04x (idx %d && %d)\n",
25962597 val, i, table[val]);
25972598
2598- for (ix = sizeof (tab) / sizeof (tab[0]); ix >= 0; ix--)
2599+ for (ix = ARRAY_SIZE (tab); ix >= 0; ix--)
25992600 if (tab[ix].index == i || tab[ix].index == j)
26002601 {
26012602 key = ((tab[ix].code[0] - '0') << 3) +
@@ -2607,7 +2608,7 @@ conflict_warn (int val, int i)
26072608 fprintf (stderr, " %s -- %s\n", tab[ix].code, tab[ix].name);
26082609 }
26092610
2610- for (ix = sizeof (movsxy_tab) / sizeof (movsxy_tab[0]); ix >= 0; ix--)
2611+ for (ix = ARRAY_SIZE (movsxy_tab); ix >= 0; ix--)
26112612 if (movsxy_tab[ix].index == i || movsxy_tab[ix].index == j)
26122613 {
26132614 key = ((movsxy_tab[ix].code[0] - '0') << 3) +
@@ -2620,7 +2621,7 @@ conflict_warn (int val, int i)
26202621 movsxy_tab[ix].code, movsxy_tab[ix].name);
26212622 }
26222623
2623- for (ix = sizeof (ppi_tab) / sizeof (ppi_tab[0]); ix >= 0; ix--)
2624+ for (ix = ARRAY_SIZE (ppi_tab); ix >= 0; ix--)
26242625 if (ppi_tab[ix].index == i || ppi_tab[ix].index == j)
26252626 {
26262627 key = ((ppi_tab[ix].code[0] - '0') << 3) +
--- a/sim/sh/interp.c
+++ b/sim/sh/interp.c
@@ -1658,7 +1658,7 @@ init_dsp (struct bfd *abfd)
16581658 {
16591659 int i, tmp;
16601660
1661- for (i = (sizeof sh_dsp_table / sizeof sh_dsp_table[0]) - 1; i >= 0; i--)
1661+ for (i = ARRAY_SIZE (sh_dsp_table) - 1; i >= 0; i--)
16621662 {
16631663 tmp = sh_jump_table[0xf000 + i];
16641664 sh_jump_table[0xf000 + i] = sh_dsp_table[i];
--- a/sim/sh64/ChangeLog
+++ b/sim/sh64/ChangeLog
@@ -1,3 +1,8 @@
1+2017-02-13 Mike Frysinger <vapier@gentoo.org>
2+
3+ * decode-compact.c (sh64_compact_init_idesc_table): Use ARRAY_SIZE.
4+ * decode-media.c (sh64_media_init_idesc_table): Likewise.
5+
16 2016-01-10 Mike Frysinger <vapier@gentoo.org>
27
38 * config.in, configure: Regenerate.
--- a/sim/sh64/decode-compact.c
+++ b/sim/sh64/decode-compact.c
@@ -292,7 +292,7 @@ sh64_compact_init_idesc_table (SIM_CPU *cpu)
292292 init_idesc (cpu, id, t);
293293
294294 /* Now fill in the values for the chosen cpu. */
295- for (t = sh64_compact_insn_sem, tend = t + sizeof (sh64_compact_insn_sem) / sizeof (*t);
295+ for (t = sh64_compact_insn_sem, tend = t + ARRAY_SIZE (sh64_compact_insn_sem);
296296 t != tend; ++t)
297297 {
298298 init_idesc (cpu, & table[t->index], t);
--- a/sim/sh64/decode-media.c
+++ b/sim/sh64/decode-media.c
@@ -306,7 +306,7 @@ sh64_media_init_idesc_table (SIM_CPU *cpu)
306306 init_idesc (cpu, id, t);
307307
308308 /* Now fill in the values for the chosen cpu. */
309- for (t = sh64_media_insn_sem, tend = t + sizeof (sh64_media_insn_sem) / sizeof (*t);
309+ for (t = sh64_media_insn_sem, tend = t + ARRAY_SIZE (sh64_media_insn_sem);
310310 t != tend; ++t)
311311 {
312312 init_idesc (cpu, & table[t->index], t);