diff options
author | Mike Frysinger <vapier@gentoo.org> | 2016-01-03 01:40:46 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2016-01-03 04:08:56 -0500 |
commit | 34fed69938f1296b62354b2a825b49602fe7af50 (patch) | |
tree | aeece93f7f3f39429d4b92cb7e4e16a6217d8f64 /sim/sh64 | |
parent | aba6f46b235a3a139c04d5ed6a3310125aa9c982 (diff) | |
download | gdb-34fed69938f1296b62354b2a825b49602fe7af50.zip gdb-34fed69938f1296b62354b2a825b49602fe7af50.tar.gz gdb-34fed69938f1296b62354b2a825b49602fe7af50.tar.bz2 |
sim: use libiberty countargv in more places
A bunch of places open code the countargv implementation, or outright
duplicate it (as count_argc). Replace all of those w/countargv.
Diffstat (limited to 'sim/sh64')
-rw-r--r-- | sim/sh64/ChangeLog | 5 | ||||
-rw-r--r-- | sim/sh64/sh64.c | 22 |
2 files changed, 8 insertions, 19 deletions
diff --git a/sim/sh64/ChangeLog b/sim/sh64/ChangeLog index d719c5c..82a06b0 100644 --- a/sim/sh64/ChangeLog +++ b/sim/sh64/ChangeLog @@ -1,5 +1,10 @@ 2016-01-03 Mike Frysinger <vapier@gentoo.org> + * sh64.c (count_argc): Delete. + (trap_handler): Change count_argc to countargv. + +2016-01-03 Mike Frysinger <vapier@gentoo.org> + * configure.ac (SIM_AC_OPTION_HOSTENDIAN): Delete. * configure: Regenerate. diff --git a/sim/sh64/sh64.c b/sim/sh64/sh64.c index c35b5c1..e239625 100644 --- a/sim/sh64/sh64.c +++ b/sim/sh64/sh64.c @@ -529,22 +529,6 @@ sh64_pref (SIM_CPU *cpu, SI addr) /* TODO: Unimplemented. */ } -/* Count the number of arguments. */ -static int -count_argc (cpu) - SIM_CPU *cpu; -{ - int i = 0; - - if (! STATE_PROG_ARGV (CPU_STATE (cpu))) - return -1; - - while (STATE_PROG_ARGV (CPU_STATE (cpu)) [i] != NULL) - ++i; - - return i; -} - /* Read a null terminated string from memory, return in a buffer */ static char * fetch_str (current_cpu, pc, addr) @@ -634,11 +618,11 @@ trap_handler (SIM_CPU *current_cpu, int shmedia_abi_p, UQI trapnum, PCADDR pc) break; case SYS_argc: - SET_H_GR (ret_reg, count_argc (current_cpu)); + SET_H_GR (ret_reg, countargv (STATE_PROG_ARGV (CPU_STATE (current_cpu)))); break; case SYS_argnlen: - if (PARM1 < count_argc (current_cpu)) + if (PARM1 < countargv (STATE_PROG_ARGV (CPU_STATE (current_cpu)))) SET_H_GR (ret_reg, strlen (STATE_PROG_ARGV (CPU_STATE (current_cpu)) [PARM1])); else @@ -646,7 +630,7 @@ trap_handler (SIM_CPU *current_cpu, int shmedia_abi_p, UQI trapnum, PCADDR pc) break; case SYS_argn: - if (PARM1 < count_argc (current_cpu)) + if (PARM1 < countargv (STATE_PROG_ARGV (CPU_STATE (current_cpu)))) { /* Include the NULL byte. */ i = strlen (STATE_PROG_ARGV (CPU_STATE (current_cpu)) [PARM1]) + 1; |