GNU Binutils with patches for OS216
Revision | 13a590ca65f744c8fa55d6e0748cb12f443493f0 (tree) |
---|---|
Zeit | 2017-02-13 15:26:21 |
Autor | Mike Frysinger <vapier@gent...> |
Commiter | Mike Frysinger |
sim: use ARRAY_SIZE instead of ad-hoc sizeof calculations
@@ -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 | + | |
1 | 9 | 2016-07-14 Nick Clifton <nickc@redhat.com> |
2 | 10 | |
3 | 11 | * armemu.c (Multiply64): Only issue error messages about invalid |
@@ -23,6 +23,7 @@ | ||
23 | 23 | |
24 | 24 | #include "config.h" |
25 | 25 | #include "ansidecl.h" |
26 | +#include "libiberty.h" | |
26 | 27 | |
27 | 28 | #include <time.h> |
28 | 29 | #include <errno.h> |
@@ -260,7 +261,7 @@ SWIopen (ARMul_State * state, ARMword name, ARMword SWIflags) | ||
260 | 261 | return; |
261 | 262 | |
262 | 263 | /* 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)) | |
264 | 265 | flags = 0; |
265 | 266 | else |
266 | 267 | flags = translate_open_mode[SWIflags]; |
@@ -17,6 +17,7 @@ | ||
17 | 17 | #include "armdefs.h" |
18 | 18 | #include "armemu.h" |
19 | 19 | #include "ansidecl.h" |
20 | +#include "libiberty.h" | |
20 | 21 | #include <math.h> |
21 | 22 | |
22 | 23 | /* Definitions for the support routines. */ |
@@ -373,7 +374,7 @@ ModeToBank (ARMword mode) | ||
373 | 374 | DUMMYBANK, DUMMYBANK, DUMMYBANK, SYSTEMBANK |
374 | 375 | }; |
375 | 376 | |
376 | - if (mode >= (sizeof (bankofmode) / sizeof (bankofmode[0]))) | |
377 | + if (mode >= ARRAY_SIZE (bankofmode)) | |
377 | 378 | return DUMMYBANK; |
378 | 379 | |
379 | 380 | return bankofmode[mode]; |
@@ -740,7 +740,7 @@ sim_target_parse_command_line (int argc, char ** argv) | ||
740 | 740 | { |
741 | 741 | int i; |
742 | 742 | |
743 | - for (i = sizeof options / sizeof options[0]; i--;) | |
743 | + for (i = ARRAY_SIZE (options); i--;) | |
744 | 744 | if (strncmp (ptr, options[i].swi_option, |
745 | 745 | strlen (options[i].swi_option)) == 0) |
746 | 746 | { |
@@ -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 | + | |
1 | 7 | 2016-01-10 Mike Frysinger <vapier@gentoo.org> |
2 | 8 | |
3 | 9 | * config.in, configure: Regenerate. |
@@ -302,7 +302,7 @@ crisv10f_init_idesc_table (SIM_CPU *cpu) | ||
302 | 302 | init_idesc (cpu, id, t); |
303 | 303 | |
304 | 304 | /* 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); | |
306 | 306 | t != tend; ++t) |
307 | 307 | { |
308 | 308 | init_idesc (cpu, & table[t->index], t); |
@@ -306,7 +306,7 @@ crisv32f_init_idesc_table (SIM_CPU *cpu) | ||
306 | 306 | init_idesc (cpu, id, t); |
307 | 307 | |
308 | 308 | /* 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); | |
310 | 310 | t != tend; ++t) |
311 | 311 | { |
312 | 312 | init_idesc (cpu, & table[t->index], t); |
@@ -786,7 +786,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd, | ||
786 | 786 | /* Note that the linux kernel does not correctly compute the storage |
787 | 787 | needs for the static-exe AUX vector. */ |
788 | 788 | |
789 | - csp -= sizeof (auxv_entries) / sizeof (auxv_entries[0]) * 4 * 2; | |
789 | + csp -= ARRAY_SIZE (auxv_entries) * 4 * 2; | |
790 | 790 | |
791 | 791 | csp -= (envc + 1) * 4; |
792 | 792 | csp -= (my_argc + 1) * 4; |
@@ -874,7 +874,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd, | ||
874 | 874 | goto abandon_chip; |
875 | 875 | |
876 | 876 | 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++) | |
878 | 878 | { |
879 | 879 | write_dword (csp, auxv_entries[i].id); |
880 | 880 | write_dword (csp + 4, |
@@ -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 | + | |
1 | 5 | 2016-01-10 Mike Frysinger <vapier@gentoo.org> |
2 | 6 | |
3 | 7 | * config.in, configure: Regenerate. |
@@ -841,7 +841,7 @@ frvbf_init_idesc_table (SIM_CPU *cpu) | ||
841 | 841 | init_idesc (cpu, id, t); |
842 | 842 | |
843 | 843 | /* 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); | |
845 | 845 | t != tend; ++t) |
846 | 846 | { |
847 | 847 | init_idesc (cpu, & table[t->index], t); |
@@ -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 | + | |
1 | 5 | 2016-01-10 Mike Frysinger <vapier@gentoo.org> |
2 | 6 | |
3 | 7 | * config.in, configure: Regenerate. |
@@ -242,7 +242,7 @@ iq2000bf_init_idesc_table (SIM_CPU *cpu) | ||
242 | 242 | init_idesc (cpu, id, t); |
243 | 243 | |
244 | 244 | /* 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); | |
246 | 246 | t != tend; ++t) |
247 | 247 | { |
248 | 248 | init_idesc (cpu, & table[t->index], t); |
@@ -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 | + | |
1 | 5 | 2016-08-15 Mike Frysinger <vapier@gentoo.org> |
2 | 6 | |
3 | 7 | * sim-if.c (find_limit): Change prototype to take a SIM_DESC. |
@@ -160,7 +160,7 @@ lm32bf_init_idesc_table (SIM_CPU *cpu) | ||
160 | 160 | init_idesc (cpu, id, t); |
161 | 161 | |
162 | 162 | /* 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); | |
164 | 164 | t != tend; ++t) |
165 | 165 | { |
166 | 166 | init_idesc (cpu, & table[t->index], t); |
@@ -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 | + | |
1 | 6 | 2016-01-10 Mike Frysinger <vapier@gentoo.org> |
2 | 7 | |
3 | 8 | * config.in, configure: Regenerate. |
@@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
22 | 22 | #include <stdio.h> |
23 | 23 | #include <stdlib.h> |
24 | 24 | |
25 | +#include "libiberty.h" | |
25 | 26 | #include "cpu.h" |
26 | 27 | #include "mem.h" |
27 | 28 |
@@ -354,7 +355,7 @@ decode_sd23 (int bbb, int bb, int bytes, int ind, int add) | ||
354 | 355 | srcdest sd; |
355 | 356 | int code = (bbb << 2) | bb; |
356 | 357 | |
357 | - if (code >= sizeof (modes23) / sizeof (modes23[0])) | |
358 | + if (code >= ARRAY_SIZE (modes23)) | |
358 | 359 | abort (); |
359 | 360 | |
360 | 361 | if (trace) |
@@ -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 | + | |
1 | 7 | 2016-01-10 Mike Frysinger <vapier@gentoo.org> |
2 | 8 | |
3 | 9 | * config.in, configure: Regenerate. |
@@ -202,7 +202,7 @@ m32rbf_init_idesc_table (SIM_CPU *cpu) | ||
202 | 202 | init_idesc (cpu, id, t); |
203 | 203 | |
204 | 204 | /* 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); | |
206 | 206 | t != tend; ++t) |
207 | 207 | { |
208 | 208 | init_idesc (cpu, & table[t->index], t); |
@@ -235,7 +235,7 @@ m32r2f_init_idesc_table (SIM_CPU *cpu) | ||
235 | 235 | init_idesc (cpu, id, t); |
236 | 236 | |
237 | 237 | /* 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); | |
239 | 239 | t != tend; ++t) |
240 | 240 | { |
241 | 241 | init_idesc (cpu, & table[t->index], t); |
@@ -228,7 +228,7 @@ m32rxf_init_idesc_table (SIM_CPU *cpu) | ||
228 | 228 | init_idesc (cpu, id, t); |
229 | 229 | |
230 | 230 | /* 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); | |
232 | 232 | t != tend; ++t) |
233 | 233 | { |
234 | 234 | init_idesc (cpu, & table[t->index], t); |
@@ -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 | + | |
1 | 10 | 2016-08-16 Mike Frysinger <vapier@gentoo.org> |
2 | 11 | |
3 | 12 | * sim-main.h (inline): Delete define. |
@@ -24,10 +24,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
24 | 24 | #include <errno.h> |
25 | 25 | |
26 | 26 | #include "ansidecl.h" |
27 | +#include "libiberty.h" | |
27 | 28 | #include "opcode/m68hc11.h" |
28 | 29 | |
29 | -#define TABLE_SIZE(X) (sizeof(X) / sizeof(X[0])) | |
30 | - | |
31 | 30 | /* Combination of CCR flags. */ |
32 | 31 | #define M6811_ZC_BIT M6811_Z_BIT|M6811_C_BIT |
33 | 32 | #define M6811_NZ_BIT M6811_N_BIT|M6811_Z_BIT |
@@ -1812,7 +1811,7 @@ find_opcode_pattern (const struct m6811_opcode_def *opcode) | ||
1812 | 1811 | { |
1813 | 1812 | pattern = opcode->name; |
1814 | 1813 | } |
1815 | - for (i = 0; i < TABLE_SIZE(m6811_opcode_patterns); i++) | |
1814 | + for (i = 0; i < ARRAY_SIZE (m6811_opcode_patterns); i++) | |
1816 | 1815 | { |
1817 | 1816 | if (strcmp (m6811_opcode_patterns[i].name, pattern) == 0) |
1818 | 1817 | { |
@@ -2036,13 +2035,13 @@ gen_interpreter (FILE *fp) | ||
2036 | 2035 | { |
2037 | 2036 | int col = 0; |
2038 | 2037 | |
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)); | |
2043 | 2042 | |
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)); | |
2046 | 2045 | |
2047 | 2046 | /* Generate header of interpretor. */ |
2048 | 2047 | print (fp, col, "/* File generated automatically by gencode. */\n"); |
@@ -2051,25 +2050,25 @@ gen_interpreter (FILE *fp) | ||
2051 | 2050 | if (cpu_type & cpu6811) |
2052 | 2051 | { |
2053 | 2052 | gen_cycle_table (fp, "cycles_page1", m6811_page1_opcodes, |
2054 | - TABLE_SIZE (m6811_page1_opcodes)); | |
2053 | + ARRAY_SIZE (m6811_page1_opcodes)); | |
2055 | 2054 | gen_cycle_table (fp, "cycles_page2", m6811_page2_opcodes, |
2056 | - TABLE_SIZE (m6811_page2_opcodes)); | |
2055 | + ARRAY_SIZE (m6811_page2_opcodes)); | |
2057 | 2056 | gen_cycle_table (fp, "cycles_page3", m6811_page3_opcodes, |
2058 | - TABLE_SIZE (m6811_page3_opcodes)); | |
2057 | + ARRAY_SIZE (m6811_page3_opcodes)); | |
2059 | 2058 | gen_cycle_table (fp, "cycles_page4", m6811_page4_opcodes, |
2060 | - TABLE_SIZE (m6811_page4_opcodes)); | |
2059 | + ARRAY_SIZE (m6811_page4_opcodes)); | |
2061 | 2060 | |
2062 | 2061 | gen_function_entry (fp, "static void\ncpu_page3_interp", 0); |
2063 | 2062 | gen_interpreter_for_table (fp, indent_level, |
2064 | 2063 | m6811_page3_opcodes, |
2065 | - TABLE_SIZE(m6811_page3_opcodes), | |
2064 | + ARRAY_SIZE (m6811_page3_opcodes), | |
2066 | 2065 | "cycles_page3"); |
2067 | 2066 | gen_function_close (fp); |
2068 | 2067 | |
2069 | 2068 | gen_function_entry (fp, "static void\ncpu_page4_interp", 0); |
2070 | 2069 | gen_interpreter_for_table (fp, indent_level, |
2071 | 2070 | m6811_page4_opcodes, |
2072 | - TABLE_SIZE(m6811_page4_opcodes), | |
2071 | + ARRAY_SIZE (m6811_page4_opcodes), | |
2073 | 2072 | "cycles_page4"); |
2074 | 2073 | gen_function_close (fp); |
2075 | 2074 |
@@ -2078,7 +2077,7 @@ gen_interpreter (FILE *fp) | ||
2078 | 2077 | USE_SRC8 | USE_DST8); |
2079 | 2078 | gen_interpreter_for_table (fp, indent_level, |
2080 | 2079 | m6811_page2_opcodes, |
2081 | - TABLE_SIZE(m6811_page2_opcodes), | |
2080 | + ARRAY_SIZE (m6811_page2_opcodes), | |
2082 | 2081 | "cycles_page2"); |
2083 | 2082 | gen_function_close (fp); |
2084 | 2083 |
@@ -2087,22 +2086,22 @@ gen_interpreter (FILE *fp) | ||
2087 | 2086 | USE_SRC8 | USE_DST8); |
2088 | 2087 | |
2089 | 2088 | gen_interpreter_for_table (fp, indent_level, m6811_page1_opcodes, |
2090 | - TABLE_SIZE(m6811_page1_opcodes), | |
2089 | + ARRAY_SIZE (m6811_page1_opcodes), | |
2091 | 2090 | "cycles_page1"); |
2092 | 2091 | gen_function_close (fp); |
2093 | 2092 | } |
2094 | 2093 | else |
2095 | 2094 | { |
2096 | 2095 | gen_cycle_table (fp, "cycles_page1", m6812_page1_opcodes, |
2097 | - TABLE_SIZE (m6812_page1_opcodes)); | |
2096 | + ARRAY_SIZE (m6812_page1_opcodes)); | |
2098 | 2097 | gen_cycle_table (fp, "cycles_page2", m6812_page2_opcodes, |
2099 | - TABLE_SIZE (m6812_page2_opcodes)); | |
2098 | + ARRAY_SIZE (m6812_page2_opcodes)); | |
2100 | 2099 | |
2101 | 2100 | gen_function_entry (fp, "static void\ncpu_page2_interp", |
2102 | 2101 | USE_SRC8 | USE_DST8); |
2103 | 2102 | gen_interpreter_for_table (fp, indent_level, |
2104 | 2103 | m6812_page2_opcodes, |
2105 | - TABLE_SIZE(m6812_page2_opcodes), | |
2104 | + ARRAY_SIZE (m6812_page2_opcodes), | |
2106 | 2105 | "cycles_page2"); |
2107 | 2106 | gen_function_close (fp); |
2108 | 2107 |
@@ -2111,7 +2110,7 @@ gen_interpreter (FILE *fp) | ||
2111 | 2110 | USE_SRC8 | USE_DST8); |
2112 | 2111 | |
2113 | 2112 | gen_interpreter_for_table (fp, indent_level, m6812_page1_opcodes, |
2114 | - TABLE_SIZE(m6812_page1_opcodes), | |
2113 | + ARRAY_SIZE (m6812_page1_opcodes), | |
2115 | 2114 | "cycles_page1"); |
2116 | 2115 | gen_function_close (fp); |
2117 | 2116 | } |
@@ -91,7 +91,6 @@ struct interrupt_def idefs[] = { | ||
91 | 91 | #endif |
92 | 92 | }; |
93 | 93 | |
94 | -#define TableSize(X) (sizeof X / sizeof(X[0])) | |
95 | 94 | #define CYCLES_MAX ((((signed64) 1) << 62) - 1) |
96 | 95 | |
97 | 96 | enum |
@@ -290,7 +289,7 @@ interrupts_update_pending (struct interrupts *interrupts) | ||
290 | 289 | set_mask = 0; |
291 | 290 | ioregs = &interrupts->cpu->ios[0]; |
292 | 291 | |
293 | - for (i = 0; i < TableSize(idefs); i++) | |
292 | + for (i = 0; i < ARRAY_SIZE (idefs); i++) | |
294 | 293 | { |
295 | 294 | struct interrupt_def *idef = &idefs[i]; |
296 | 295 | uint8 data; |
@@ -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 | + | |
1 | 13 | 2016-01-10 Mike Frysinger <vapier@gentoo.org> |
2 | 14 | |
3 | 15 | * configure.ac (sim-assert): Call AC_MSG_CHECKING, |
@@ -34,6 +34,7 @@ | ||
34 | 34 | #include "os_emul.h" |
35 | 35 | #include "mon.h" |
36 | 36 | #include "model.h" |
37 | +#include "libiberty.h" | |
37 | 38 | |
38 | 39 | #ifndef CONST_ATTRIBUTE |
39 | 40 | #define CONST_ATTRIBUTE __attribute__((__const__)) |
@@ -339,7 +339,7 @@ emul_bugapi_instruction_name(int call_id) | ||
339 | 339 | static char buffer[40]; |
340 | 340 | int i; |
341 | 341 | |
342 | - for (i = 0; i < sizeof (bug_mapping) / sizeof (bug_mapping[0]); i++) | |
342 | + for (i = 0; i < ARRAY_SIZE (bug_mapping); i++) | |
343 | 343 | { |
344 | 344 | if (bug_mapping[i].value == call_id) |
345 | 345 | return bug_mapping[i].info; |
@@ -28,6 +28,7 @@ | ||
28 | 28 | #include "tree.h" |
29 | 29 | |
30 | 30 | #include "bfd.h" |
31 | +#include "libiberty.h" | |
31 | 32 | |
32 | 33 | #ifndef INLINE_EMUL_GENERIC |
33 | 34 | #define INLINE_EMUL_GENERIC |
@@ -1413,11 +1413,11 @@ static char *(netbsd_signal_names[]) = { | ||
1413 | 1413 | |
1414 | 1414 | static emul_syscall emul_netbsd_syscalls = { |
1415 | 1415 | netbsd_descriptors, |
1416 | - sizeof(netbsd_descriptors) / sizeof(netbsd_descriptors[0]), | |
1416 | + ARRAY_SIZE (netbsd_descriptors), | |
1417 | 1417 | netbsd_error_names, |
1418 | - sizeof(netbsd_error_names) / sizeof(netbsd_error_names[0]), | |
1418 | + ARRAY_SIZE (netbsd_error_names), | |
1419 | 1419 | netbsd_signal_names, |
1420 | - sizeof(netbsd_signal_names) / sizeof(netbsd_signal_names[0]), | |
1420 | + ARRAY_SIZE (netbsd_signal_names), | |
1421 | 1421 | }; |
1422 | 1422 | |
1423 | 1423 |
@@ -1147,15 +1147,15 @@ convert_to_solaris_stat(unsigned_word addr, | ||
1147 | 1147 | target.st_mtim.tv_sec = H2T_4(host->st_mtime); |
1148 | 1148 | target.st_mtim.tv_usec = 0; |
1149 | 1149 | |
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++) | |
1151 | 1151 | target.st_pad1[i] = 0; |
1152 | 1152 | |
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++) | |
1154 | 1154 | target.st_pad2[i] = 0; |
1155 | 1155 | |
1156 | 1156 | target.st_pad3 = 0; |
1157 | 1157 | |
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++) | |
1159 | 1159 | target.st_pad4[i] = 0; |
1160 | 1160 | |
1161 | 1161 | /* For now, just punt and always say it is a ufs file */ |
@@ -1945,11 +1945,11 @@ static char *(solaris_signal_names[]) = { | ||
1945 | 1945 | |
1946 | 1946 | static emul_syscall emul_solaris_syscalls = { |
1947 | 1947 | solaris_descriptors, |
1948 | - sizeof(solaris_descriptors) / sizeof(solaris_descriptors[0]), | |
1948 | + ARRAY_SIZE (solaris_descriptors), | |
1949 | 1949 | solaris_error_names, |
1950 | - sizeof(solaris_error_names) / sizeof(solaris_error_names[0]), | |
1950 | + ARRAY_SIZE (solaris_error_names), | |
1951 | 1951 | solaris_signal_names, |
1952 | - sizeof(solaris_signal_names) / sizeof(solaris_signal_names[0]), | |
1952 | + ARRAY_SIZE (solaris_signal_names), | |
1953 | 1953 | }; |
1954 | 1954 | |
1955 | 1955 |
@@ -2824,11 +2824,11 @@ static char *(linux_signal_names[]) = { | ||
2824 | 2824 | |
2825 | 2825 | static emul_syscall emul_linux_syscalls = { |
2826 | 2826 | linux_descriptors, |
2827 | - sizeof(linux_descriptors) / sizeof(linux_descriptors[0]), | |
2827 | + ARRAY_SIZE (linux_descriptors), | |
2828 | 2828 | linux_error_names, |
2829 | - sizeof(linux_error_names) / sizeof(linux_error_names[0]), | |
2829 | + ARRAY_SIZE (linux_error_names), | |
2830 | 2830 | linux_signal_names, |
2831 | - sizeof(linux_signal_names) / sizeof(linux_signal_names[0]), | |
2831 | + ARRAY_SIZE (linux_signal_names), | |
2832 | 2832 | }; |
2833 | 2833 | |
2834 | 2834 |
@@ -216,7 +216,7 @@ print_options (void) | ||
216 | 216 | int max_len = 0; |
217 | 217 | int cols; |
218 | 218 | |
219 | - for (i = 0; i < sizeof (defines) / sizeof (defines[0]); i++) { | |
219 | + for (i = 0; i < ARRAY_SIZE (defines); i++) { | |
220 | 220 | int len = strlen (defines[i]); |
221 | 221 | if (len > max_len) |
222 | 222 | max_len = len; |
@@ -227,10 +227,10 @@ print_options (void) | ||
227 | 227 | cols = 1; |
228 | 228 | |
229 | 229 | printf_filtered ("\n#defines:"); |
230 | - for (i = 0; i < sizeof (defines) / sizeof (defines[0]); i++) { | |
230 | + for (i = 0; i < ARRAY_SIZE (defines); i++) { | |
231 | 231 | const char *const prefix = ((i % cols) == 0) ? "\n" : ""; |
232 | 232 | printf_filtered ("%s %s%*s", prefix, defines[i], |
233 | - (((i == (sizeof (defines) / sizeof (defines[0])) - 1) | |
233 | + (((i == ARRAY_SIZE (defines) - 1) | |
234 | 234 | || (((i + 1) % cols) == 0)) |
235 | 235 | ? 0 |
236 | 236 | : max_len + 4 - strlen (defines[i])), |
@@ -908,7 +908,7 @@ model_print *::model-function::model_mon_info:model_data *model_ptr | ||
908 | 908 | tail->suffix_singular = ""; |
909 | 909 | } |
910 | 910 | |
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++) { | |
912 | 912 | if (model_ptr->nr_branch_conditional[j]) { |
913 | 913 | tail->next = ZALLOC(model_print); |
914 | 914 | tail = tail->next; |
@@ -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 | + | |
1 | 6 | 2016-07-27 Alan Modra <amodra@gmail.com> |
2 | 7 | |
3 | 8 | * load.c: Don't include libbfd.h. |
@@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
23 | 23 | #include <stdlib.h> |
24 | 24 | #include <string.h> |
25 | 25 | #include <signal.h> |
26 | +#include "libiberty.h" | |
26 | 27 | |
27 | 28 | #include "opcode/rx.h" |
28 | 29 | #include "cpu.h" |
@@ -151,8 +152,8 @@ static const char * optype_names[] = { | ||
151 | 152 | "RbRi" /* [Rb + scale * Ri] */ |
152 | 153 | }; |
153 | 154 | |
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) | |
156 | 157 | #define N_MAP 90 |
157 | 158 | |
158 | 159 | static unsigned long long benchmark_start_cycle; |
@@ -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 | + | |
1 | 7 | 2016-04-10 Oleg Endo <olegendo@gcc.gnu.org> |
2 | 8 | |
3 | 9 | * interp.c (dmul): Split into dmul_s and dmul_u. Use explicit integer |
@@ -35,6 +35,7 @@ | ||
35 | 35 | #include <stdlib.h> |
36 | 36 | #include <string.h> |
37 | 37 | #include <unistd.h> |
38 | +#include "libiberty.h" | |
38 | 39 | |
39 | 40 | #define MAX_NR_STUFF 42 |
40 | 41 |
@@ -2595,7 +2596,7 @@ conflict_warn (int val, int i) | ||
2595 | 2596 | fprintf (stderr, "Warning: opcode table conflict: 0x%04x (idx %d && %d)\n", |
2596 | 2597 | val, i, table[val]); |
2597 | 2598 | |
2598 | - for (ix = sizeof (tab) / sizeof (tab[0]); ix >= 0; ix--) | |
2599 | + for (ix = ARRAY_SIZE (tab); ix >= 0; ix--) | |
2599 | 2600 | if (tab[ix].index == i || tab[ix].index == j) |
2600 | 2601 | { |
2601 | 2602 | key = ((tab[ix].code[0] - '0') << 3) + |
@@ -2607,7 +2608,7 @@ conflict_warn (int val, int i) | ||
2607 | 2608 | fprintf (stderr, " %s -- %s\n", tab[ix].code, tab[ix].name); |
2608 | 2609 | } |
2609 | 2610 | |
2610 | - for (ix = sizeof (movsxy_tab) / sizeof (movsxy_tab[0]); ix >= 0; ix--) | |
2611 | + for (ix = ARRAY_SIZE (movsxy_tab); ix >= 0; ix--) | |
2611 | 2612 | if (movsxy_tab[ix].index == i || movsxy_tab[ix].index == j) |
2612 | 2613 | { |
2613 | 2614 | key = ((movsxy_tab[ix].code[0] - '0') << 3) + |
@@ -2620,7 +2621,7 @@ conflict_warn (int val, int i) | ||
2620 | 2621 | movsxy_tab[ix].code, movsxy_tab[ix].name); |
2621 | 2622 | } |
2622 | 2623 | |
2623 | - for (ix = sizeof (ppi_tab) / sizeof (ppi_tab[0]); ix >= 0; ix--) | |
2624 | + for (ix = ARRAY_SIZE (ppi_tab); ix >= 0; ix--) | |
2624 | 2625 | if (ppi_tab[ix].index == i || ppi_tab[ix].index == j) |
2625 | 2626 | { |
2626 | 2627 | key = ((ppi_tab[ix].code[0] - '0') << 3) + |
@@ -1658,7 +1658,7 @@ init_dsp (struct bfd *abfd) | ||
1658 | 1658 | { |
1659 | 1659 | int i, tmp; |
1660 | 1660 | |
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--) | |
1662 | 1662 | { |
1663 | 1663 | tmp = sh_jump_table[0xf000 + i]; |
1664 | 1664 | sh_jump_table[0xf000 + i] = sh_dsp_table[i]; |
@@ -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 | + | |
1 | 6 | 2016-01-10 Mike Frysinger <vapier@gentoo.org> |
2 | 7 | |
3 | 8 | * config.in, configure: Regenerate. |
@@ -292,7 +292,7 @@ sh64_compact_init_idesc_table (SIM_CPU *cpu) | ||
292 | 292 | init_idesc (cpu, id, t); |
293 | 293 | |
294 | 294 | /* 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); | |
296 | 296 | t != tend; ++t) |
297 | 297 | { |
298 | 298 | init_idesc (cpu, & table[t->index], t); |
@@ -306,7 +306,7 @@ sh64_media_init_idesc_table (SIM_CPU *cpu) | ||
306 | 306 | init_idesc (cpu, id, t); |
307 | 307 | |
308 | 308 | /* 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); | |
310 | 310 | t != tend; ++t) |
311 | 311 | { |
312 | 312 | init_idesc (cpu, & table[t->index], t); |