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/ppc | |
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/ppc')
-rw-r--r-- | sim/ppc/ChangeLog | 12 | ||||
-rw-r--r-- | sim/ppc/cpu.h | 1 | ||||
-rw-r--r-- | sim/ppc/emul_bugapi.c | 2 | ||||
-rw-r--r-- | sim/ppc/emul_generic.h | 1 | ||||
-rw-r--r-- | sim/ppc/emul_netbsd.c | 6 | ||||
-rw-r--r-- | sim/ppc/emul_unix.c | 18 | ||||
-rw-r--r-- | sim/ppc/options.c | 6 | ||||
-rw-r--r-- | sim/ppc/ppc-instructions | 2 |
8 files changed, 31 insertions, 17 deletions
diff --git a/sim/ppc/ChangeLog b/sim/ppc/ChangeLog index 7ed024e..c0bb1f5 100644 --- a/sim/ppc/ChangeLog +++ b/sim/ppc/ChangeLog @@ -1,3 +1,15 @@ +2017-02-13 Mike Frysinger <vapier@gentoo.org> + + * cpu.h: Include libiberty.h. + * emul_bugapi.c (emul_bugapi_instruction_name): Use ARRAY_SIZE. + * emul_generic.h: Include libiberty.h. + * emul_netbsd.c (emul_netbsd_syscalls): Use ARRAY_SIZE. + * emul_unix.c (convert_to_solaris_stat): Likewise. + (emul_solaris_syscalls): Likewise. + (emul_linux_syscalls): Likewise. + * options.c (print_options): Likewise. + * ppc-instructions: Likewise. + 2016-01-10 Mike Frysinger <vapier@gentoo.org> * configure.ac (sim-assert): Call AC_MSG_CHECKING, diff --git a/sim/ppc/cpu.h b/sim/ppc/cpu.h index cb141f2..bafb5e1 100644 --- a/sim/ppc/cpu.h +++ b/sim/ppc/cpu.h @@ -34,6 +34,7 @@ #include "os_emul.h" #include "mon.h" #include "model.h" +#include "libiberty.h" #ifndef CONST_ATTRIBUTE #define CONST_ATTRIBUTE __attribute__((__const__)) diff --git a/sim/ppc/emul_bugapi.c b/sim/ppc/emul_bugapi.c index e33d0cf..8481b6f 100644 --- a/sim/ppc/emul_bugapi.c +++ b/sim/ppc/emul_bugapi.c @@ -339,7 +339,7 @@ emul_bugapi_instruction_name(int call_id) static char buffer[40]; int i; - for (i = 0; i < sizeof (bug_mapping) / sizeof (bug_mapping[0]); i++) + for (i = 0; i < ARRAY_SIZE (bug_mapping); i++) { if (bug_mapping[i].value == call_id) return bug_mapping[i].info; diff --git a/sim/ppc/emul_generic.h b/sim/ppc/emul_generic.h index e697abd..9ea23d4 100644 --- a/sim/ppc/emul_generic.h +++ b/sim/ppc/emul_generic.h @@ -28,6 +28,7 @@ #include "tree.h" #include "bfd.h" +#include "libiberty.h" #ifndef INLINE_EMUL_GENERIC #define INLINE_EMUL_GENERIC diff --git a/sim/ppc/emul_netbsd.c b/sim/ppc/emul_netbsd.c index 12dfb21..9b80fc2 100644 --- a/sim/ppc/emul_netbsd.c +++ b/sim/ppc/emul_netbsd.c @@ -1413,11 +1413,11 @@ static char *(netbsd_signal_names[]) = { static emul_syscall emul_netbsd_syscalls = { netbsd_descriptors, - sizeof(netbsd_descriptors) / sizeof(netbsd_descriptors[0]), + ARRAY_SIZE (netbsd_descriptors), netbsd_error_names, - sizeof(netbsd_error_names) / sizeof(netbsd_error_names[0]), + ARRAY_SIZE (netbsd_error_names), netbsd_signal_names, - sizeof(netbsd_signal_names) / sizeof(netbsd_signal_names[0]), + ARRAY_SIZE (netbsd_signal_names), }; diff --git a/sim/ppc/emul_unix.c b/sim/ppc/emul_unix.c index 1475474..3a1c245 100644 --- a/sim/ppc/emul_unix.c +++ b/sim/ppc/emul_unix.c @@ -1147,15 +1147,15 @@ convert_to_solaris_stat(unsigned_word addr, target.st_mtim.tv_sec = H2T_4(host->st_mtime); target.st_mtim.tv_usec = 0; - for (i = 0; i < sizeof (target.st_pad1) / sizeof (target.st_pad1[0]); i++) + for (i = 0; i < ARRAY_SIZE (target.st_pad1); i++) target.st_pad1[i] = 0; - for (i = 0; i < sizeof (target.st_pad2) / sizeof (target.st_pad2[0]); i++) + for (i = 0; i < ARRAY_SIZE (target.st_pad2); i++) target.st_pad2[i] = 0; target.st_pad3 = 0; - for (i = 0; i < sizeof (target.st_pad4) / sizeof (target.st_pad4[0]); i++) + for (i = 0; i < ARRAY_SIZE (target.st_pad4); i++) target.st_pad4[i] = 0; /* For now, just punt and always say it is a ufs file */ @@ -1945,11 +1945,11 @@ static char *(solaris_signal_names[]) = { static emul_syscall emul_solaris_syscalls = { solaris_descriptors, - sizeof(solaris_descriptors) / sizeof(solaris_descriptors[0]), + ARRAY_SIZE (solaris_descriptors), solaris_error_names, - sizeof(solaris_error_names) / sizeof(solaris_error_names[0]), + ARRAY_SIZE (solaris_error_names), solaris_signal_names, - sizeof(solaris_signal_names) / sizeof(solaris_signal_names[0]), + ARRAY_SIZE (solaris_signal_names), }; @@ -2824,11 +2824,11 @@ static char *(linux_signal_names[]) = { static emul_syscall emul_linux_syscalls = { linux_descriptors, - sizeof(linux_descriptors) / sizeof(linux_descriptors[0]), + ARRAY_SIZE (linux_descriptors), linux_error_names, - sizeof(linux_error_names) / sizeof(linux_error_names[0]), + ARRAY_SIZE (linux_error_names), linux_signal_names, - sizeof(linux_signal_names) / sizeof(linux_signal_names[0]), + ARRAY_SIZE (linux_signal_names), }; diff --git a/sim/ppc/options.c b/sim/ppc/options.c index 169378e..ddb492f 100644 --- a/sim/ppc/options.c +++ b/sim/ppc/options.c @@ -216,7 +216,7 @@ print_options (void) int max_len = 0; int cols; - for (i = 0; i < sizeof (defines) / sizeof (defines[0]); i++) { + for (i = 0; i < ARRAY_SIZE (defines); i++) { int len = strlen (defines[i]); if (len > max_len) max_len = len; @@ -227,10 +227,10 @@ print_options (void) cols = 1; printf_filtered ("\n#defines:"); - for (i = 0; i < sizeof (defines) / sizeof (defines[0]); i++) { + for (i = 0; i < ARRAY_SIZE (defines); i++) { const char *const prefix = ((i % cols) == 0) ? "\n" : ""; printf_filtered ("%s %s%*s", prefix, defines[i], - (((i == (sizeof (defines) / sizeof (defines[0])) - 1) + (((i == ARRAY_SIZE (defines) - 1) || (((i + 1) % cols) == 0)) ? 0 : max_len + 4 - strlen (defines[i])), diff --git a/sim/ppc/ppc-instructions b/sim/ppc/ppc-instructions index 1a2e51a..5e6d21d 100644 --- 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 tail->suffix_singular = ""; } - for (j = 0; j < (sizeof(ppc_branch_conditional_name) / sizeof(ppc_branch_conditional_name[0])) ; j++) { + for (j = 0; j < ARRAY_SIZE (ppc_branch_conditional_name); j++) { if (model_ptr->nr_branch_conditional[j]) { tail->next = ZALLOC(model_print); tail = tail->next; |