+2016-01-03 Mike Frysinger <vapier@gentoo.org>
+
+ * wrapper.c (sim_target_parse_arg_array): Replace for loop with
+ a call to countargv.
+
2016-01-03 Mike Frysinger <vapier@gentoo.org>
* configure.ac (SIM_AC_OPTION_HOSTENDIAN): Delete.
static void
sim_target_parse_arg_array (char ** argv)
{
- int i;
-
- for (i = 0; argv[i]; i++)
- ;
-
- sim_target_parse_command_line (i, argv);
+ sim_target_parse_command_line (countargv (argv), argv);
}
static sim_cia
+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.
"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. */
#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;
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);
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 */
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]);
+2016-01-03 Mike Frysinger <vapier@gentoo.org>
+
+ * sim-options.c (sim_parse_args): Replace for loop with a call
+ to countargv.
+
2016-01-03 Mike Frysinger <vapier@gentoo.org>
* nrun.c (myname): Mark const.
SIM_RC result = SIM_RC_OK;
/* Count the number of arguments. */
- for (argc = 0; argv[argc] != NULL; ++argc)
- continue;
+ argc = countargv (argv);
/* Count the number of options. */
num_opts = 0;
+2016-01-03 Mike Frysinger <vapier@gentoo.org>
+
+ * interf.c (sim_open): Replace while loop with a call to countargv.
+
2016-01-03 Mike Frysinger <vapier@gentoo.org>
* configure.ac (SIM_AC_OPTION_HOSTENDIAN): Delete.
sim_callback = callback;
- while (argv[argc])
- argc++;
+ argc = countargv (argv);
while (stat < argc) {
if (argv[stat][0] == '-') {
if (strcmp(argv[stat], "-v") == 0) {
+2016-01-03 Mike Frysinger <vapier@gentoo.org>
+
+ * interp.c (count_argc): Delete.
+ (trap): Change count_argc to countargv.
+
2016-01-03 Mike Frysinger <vapier@gentoo.org>
* configure.ac (SIM_AC_OPTION_HOSTENDIAN): Delete.
#define FPSCR_SZ ((GET_FPSCR () & FPSCR_MASK_SZ) != 0)
#define FPSCR_PR ((GET_FPSCR () & FPSCR_MASK_PR) != 0)
-/* Count the number of arguments in an argv. */
-static int
-count_argc (char **argv)
-{
- int i;
-
- if (! argv)
- return -1;
-
- for (i = 0; argv[i] != NULL; ++i)
- continue;
- return i;
-}
-
static void
set_fpscr1 (int x)
{
break;
}
case SYS_argc:
- regs[0] = count_argc (prog_argv);
+ regs[0] = countargv (prog_argv);
break;
case SYS_argnlen:
- if (regs[5] < count_argc (prog_argv))
+ if (regs[5] < countargv (prog_argv))
regs[0] = strlen (prog_argv[regs[5]]);
else
regs[0] = -1;
break;
case SYS_argn:
- if (regs[5] < count_argc (prog_argv))
+ if (regs[5] < countargv (prog_argv))
{
/* Include the termination byte. */
int i = strlen (prog_argv[regs[5]]) + 1;
+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.
/* 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)
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
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;