aboutsummaryrefslogtreecommitdiff
path: root/sim/bfin
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2016-01-03 01:40:46 -0500
committerMike Frysinger <vapier@gentoo.org>2016-01-03 04:08:56 -0500
commit34fed69938f1296b62354b2a825b49602fe7af50 (patch)
treeaeece93f7f3f39429d4b92cb7e4e16a6217d8f64 /sim/bfin
parentaba6f46b235a3a139c04d5ed6a3310125aa9c982 (diff)
downloadfsf-binutils-gdb-34fed69938f1296b62354b2a825b49602fe7af50.zip
fsf-binutils-gdb-34fed69938f1296b62354b2a825b49602fe7af50.tar.gz
fsf-binutils-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/bfin')
-rw-r--r--sim/bfin/ChangeLog6
-rw-r--r--sim/bfin/interp.c24
2 files changed, 11 insertions, 19 deletions
diff --git a/sim/bfin/ChangeLog b/sim/bfin/ChangeLog
index fe7f6a6..ce03a80 100644
--- a/sim/bfin/ChangeLog
+++ b/sim/bfin/ChangeLog
@@ -1,5 +1,11 @@
2016-01-03 Mike Frysinger <vapier@gentoo.org>
+ * interp.c (count_argc): Delete.
+ (bfin_syscall): Change count_argc to countargv.
+ (bfin_user_init): Likewise.
+
+2016-01-03 Mike Frysinger <vapier@gentoo.org>
+
* configure.ac (SIM_AC_OPTION_HOSTENDIAN): Delete.
* configure: Regenerate.
diff --git a/sim/bfin/interp.c b/sim/bfin/interp.c
index 10b331f..84fb085 100644
--- a/sim/bfin/interp.c
+++ b/sim/bfin/interp.c
@@ -112,20 +112,6 @@ static const char cb_libgloss_stat_map_32[] =
"space,4:st_blksize,4:st_blocks,4:space,8";
static const char *stat_map_32, *stat_map_64;
-/* Count the number of arguments in an argv. */
-static int
-count_argc (const char * const *argv)
-{
- int i;
-
- if (! argv)
- return -1;
-
- for (i = 0; argv[i] != NULL; ++i)
- continue;
- return i;
-}
-
/* Simulate a monitor trap, put the result into r0 and errno into r1
return offset by which to adjust pc. */
@@ -180,12 +166,12 @@ bfin_syscall (SIM_CPU *cpu)
#ifdef CB_SYS_argc
case CB_SYS_argc:
tbuf += sprintf (tbuf, "argc()");
- sc.result = count_argc (argv);
+ sc.result = countargv ((char **)argv);
break;
case CB_SYS_argnlen:
{
tbuf += sprintf (tbuf, "argnlen(%u)", args[0]);
- if (sc.arg1 < count_argc (argv))
+ if (sc.arg1 < countargv ((char **)argv))
sc.result = strlen (argv[sc.arg1]);
else
sc.result = -1;
@@ -194,7 +180,7 @@ bfin_syscall (SIM_CPU *cpu)
case CB_SYS_argn:
{
tbuf += sprintf (tbuf, "argn(%u)", args[0]);
- if (sc.arg1 < count_argc (argv))
+ if (sc.arg1 < countargv ((char **)argv))
{
const char *argn = argv[sc.arg1];
int len = strlen (argn);
@@ -1073,7 +1059,7 @@ bfin_user_init (SIM_DESC sd, SIM_CPU *cpu, struct bfd *abfd,
sim_pc_set (cpu, elf_addrs[0]);
/* Figure out how much storage the argv/env strings need. */
- argc = count_argc (argv);
+ argc = countargv ((char **)argv);
if (argc == -1)
argc = 0;
argv_flat = argc; /* NUL bytes */
@@ -1082,7 +1068,7 @@ bfin_user_init (SIM_DESC sd, SIM_CPU *cpu, struct bfd *abfd,
if (!env)
env = simple_env;
- envc = count_argc (env);
+ envc = countargv ((char **)env);
env_flat = envc; /* NUL bytes */
for (i = 0; i < envc; ++i)
env_flat += strlen (env[i]);