+2015-03-28 Mike Frysinger <vapier@gentoo.org>
+
+ * gencode.c (ppi_gensim): Convert old style prototype with ppi_insn.
+ * interp.c: Include ctype.h and run-sim.h.
+ [HAVE_TIME_H]: Include time.h
+ [HAVE_SYS_TIME_H]: Include sys/time.h
+ [!_WIN32]: Include utime.h and sys/wait.h.
+ (set_fpscr1, raise_exception, raise_buserror, get_dr, set_dr, set_sr,
+ do_rdat, do_wdat, process_wlat_addr, process_wwat_addr,
+ process_wbat_addr, process_rlat_addr, process_rwat_addr,
+ process_rbat_addr, IOMEM, get_now, now_persec, swapout, swapout16,
+ ptr, strswaplen, strnswap, dmul, macw, macl, get_loop_bounds_ext,
+ get_loop_bounds, sim_size, init_dsp, init_pointers, dump_profile,
+ gotcall, sim_stop, sim_write, sim_read, sim_store_register,
+ sim_fetch_register, sim_trace, sim_stop_reason, sim_info,
+ sim_set_profile, sim_set_profile_size, sim_open,
+ parse_and_set_memory_size, sim_close, sim_load, sim_create_inferior,
+ sim_do_command, sim_set_callbacks): Convert old style prototype.
+ (fail): Delete unused function.
+ (wlat_fast, wwat_fast, wbat_fast, rlat_fast, rwat_fast, rbat_fast):
+ Delete unused prototypes.
+ (wlat_fast, wwat_fast, wbat_fast, rlat_fast, rwat_fast, rbat_fast,
+ swap, swap16):
+ Convert old style prototype and move INLINE before the type.
+ (trap): Convert old style prototype. Add casts to wait and sim_write
+ calls.
+ (div1): Convert old style prototype. Change return to void.
+ (do_long_move_insn, do_blog_insn, fsca_s, fsrra_s, mcalloc): Mark
+ static.
+ (sim_resume): Convert old style prototype. Align printf format and
+ args.
+
2015-03-28 Mike Frysinger <vapier@gentoo.org>
* gencode.c (ppi_gensim): Add missing */. Change case 4 to case 5.
#include "config.h"
+#include <ctype.h>
#include <stdio.h>
#include <errno.h>
#include <signal.h>
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
+#ifdef HAVE_TIME_H
+#include <time.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#ifndef _WIN32
+#include <utime.h>
+#include <sys/wait.h>
+#endif
#include "bfd.h"
#include "gdb/callback.h"
#include "gdb/remote-sim.h"
#include "gdb/sim-sh.h"
+#include "run-sim.h"
/* This file is local - if newlib changes, then so should this. */
#include "syscall.h"
}
static void
-set_fpscr1 (x)
- int x;
+set_fpscr1 (int x)
{
int old = saved_state.asregs.sregs.named.fpscr;
saved_state.asregs.sregs.named.fpscr = (x);
#define DSR (saved_state.asregs.sregs.named.fpscr)
-int
-fail ()
-{
- abort ();
-}
-
#define RAISE_EXCEPTION(x) \
(saved_state.asregs.exception = x, saved_state.asregs.insn_end = 0)
/* This function exists mainly for the purpose of setting a breakpoint to
catch simulated bus errors when running the simulator under GDB. */
-void
-raise_exception (x)
- int x;
+static void
+raise_exception (int x)
{
RAISE_EXCEPTION (x);
}
-void
-raise_buserror ()
+static void
+raise_buserror (void)
{
raise_exception (SIGBUS);
}
static int process_rlat_addr (int);
static int process_rwat_addr (int);
static int process_rbat_addr (int);
-static void INLINE wlat_fast (unsigned char *, int, int, int);
-static void INLINE wwat_fast (unsigned char *, int, int, int, int);
-static void INLINE wbat_fast (unsigned char *, int, int, int);
-static int INLINE rlat_fast (unsigned char *, int, int);
-static int INLINE rwat_fast (unsigned char *, int, int, int);
-static int INLINE rbat_fast (unsigned char *, int, int);
static host_callback *callback;
#define DR(n) (get_dr (n))
static double
-get_dr (n)
- int n;
+get_dr (int n)
{
n = (n & ~1);
if (host_little_endian)
#define SET_DR(n, EXP) set_dr ((n), (EXP))
static void
-set_dr (n, exp)
- int n;
- double exp;
+set_dr (int n, double exp)
{
n = (n & ~1);
if (host_little_endian)
} while (0)
static void
-set_sr (new_sr)
- int new_sr;
+set_sr (int new_sr)
{
/* do we need to swap banks */
int old_gpr = SR_MD && SR_RB;
SET_MOD (MOD);
}
-static void INLINE
-wlat_fast (memory, x, value, maskl)
- unsigned char *memory;
+static INLINE void
+wlat_fast (unsigned char *memory, int x, int value, int maskl)
{
int v = value;
unsigned int *p = (unsigned int *) (memory + x);
*p = v;
}
-static void INLINE
-wwat_fast (memory, x, value, maskw, endianw)
- unsigned char *memory;
+static INLINE void
+wwat_fast (unsigned char *memory, int x, int value, int maskw, int endianw)
{
int v = value;
unsigned short *p = (unsigned short *) (memory + (x ^ endianw));
*p = v;
}
-static void INLINE
-wbat_fast (memory, x, value, maskb)
- unsigned char *memory;
+static INLINE void
+wbat_fast (unsigned char *memory, int x, int value, int maskb)
{
unsigned char *p = memory + (x ^ endianb);
WRITE_BUSERROR (x, maskb, value, process_wbat_addr);
/* Read functions */
-static int INLINE
-rlat_fast (memory, x, maskl)
- unsigned char *memory;
+static INLINE int
+rlat_fast (unsigned char *memory, int x, int maskl)
{
unsigned int *p = (unsigned int *) (memory + x);
READ_BUSERROR (x, maskl, process_rlat_addr);
return *p;
}
-static int INLINE
-rwat_fast (memory, x, maskw, endianw)
- unsigned char *memory;
- int x, maskw, endianw;
+static INLINE int
+rwat_fast (unsigned char *memory, int x, int maskw, int endianw)
{
unsigned short *p = (unsigned short *) (memory + (x ^ endianw));
READ_BUSERROR (x, maskw, process_rwat_addr);
return *p;
}
-static int INLINE
-riat_fast (insn_ptr, endianw)
- unsigned char *insn_ptr;
+static INLINE int
+riat_fast (unsigned char *insn_ptr, int endianw)
{
unsigned short *p = (unsigned short *) ((size_t) insn_ptr ^ endianw);
return *p;
}
-static int INLINE
-rbat_fast (memory, x, maskb)
- unsigned char *memory;
+static INLINE int
+rbat_fast (unsigned char *memory, int x, int maskb)
{
unsigned char *p = memory + (x ^ endianb);
READ_BUSERROR (x, maskb, process_rbat_addr);
#define RDAT(x, n) (do_rdat (memory, (x), (n), (maskl)))
static int
-do_rdat (memory, x, n, maskl)
- char *memory;
- int x;
- int n;
- int maskl;
+do_rdat (unsigned char *memory, int x, int n, int maskl)
{
int f0;
int f1;
#define WDAT(x, n) (do_wdat (memory, (x), (n), (maskl)))
static int
-do_wdat (memory, x, n, maskl)
- char *memory;
- int x;
- int n;
- int maskl;
+do_wdat (unsigned char *memory, int x, int n, int maskl)
{
int f0;
int f1;
}
static void
-process_wlat_addr (addr, value)
- int addr;
- int value;
+process_wlat_addr (int addr, int value)
{
unsigned int *ptr;
}
static void
-process_wwat_addr (addr, value)
- int addr;
- int value;
+process_wwat_addr (int addr, int value)
{
unsigned short *ptr;
}
static void
-process_wbat_addr (addr, value)
- int addr;
- int value;
+process_wbat_addr (int addr, int value)
{
unsigned char *ptr;
}
static int
-process_rlat_addr (addr)
- int addr;
+process_rlat_addr (int addr)
{
unsigned char *ptr;
}
static int
-process_rwat_addr (addr)
- int addr;
+process_rwat_addr (int addr)
{
unsigned char *ptr;
}
static int
-process_rbat_addr (addr)
- int addr;
+process_rbat_addr (int addr)
{
unsigned char *ptr;
#define SCI_TDRE 0x80 /* Transmit data register empty */
static int
-IOMEM (addr, write, value)
- int addr;
- int write;
- int value;
+IOMEM (int addr, int write, int value)
{
if (write)
{
}
static int
-get_now ()
+get_now (void)
{
return time ((long *) 0);
}
static int
-now_persec ()
+now_persec (void)
{
return 1;
}
static FILE *profile_file;
-static unsigned INLINE
-swap (n)
- unsigned n;
+static INLINE unsigned
+swap (unsigned n)
{
if (endianb)
n = (n << 24 | (n & 0xff00) << 8
return n;
}
-static unsigned short INLINE
-swap16 (n)
- unsigned short n;
+static INLINE unsigned short
+swap16 (unsigned short n)
{
if (endianb)
n = n << 8 | (n & 0xff00) >> 8;
}
static void
-swapout (n)
- int n;
+swapout (int n)
{
if (profile_file)
{
}
static void
-swapout16 (n)
- int n;
+swapout16 (int n)
{
union { char b[4]; int n; } u;
u.n = swap16 (n);
/* Turn a pointer in a register into a pointer into real memory. */
static char *
-ptr (x)
- int x;
+ptr (int x)
{
return (char *) (x + saved_state.asregs.memory);
}
to use this string as a zero-terminated string on the host.
(Not counting the rounding up needed to operate on entire words.) */
static int
-strswaplen (str)
- int str;
+strswaplen (int str)
{
unsigned char *memory = saved_state.asregs.memory;
int start, end;
}
static void
-strnswap (str, len)
- int str;
- int len;
+strnswap (int str, int len)
{
int *start, *end;
return offset by which to adjust pc. */
static int
-trap (i, regs, insn_ptr, memory, maskl, maskw, endianw)
- int i;
- int *regs;
- unsigned char *insn_ptr;
- unsigned char *memory;
+trap (int i, int *regs, unsigned char *insn_ptr, unsigned char *memory,
+ int maskl, int maskw, int endianw)
{
switch (i)
{
break;
case SYS_wait:
- regs[0] = wait (ptr (regs[5]));
+ regs[0] = wait ((int *) ptr (regs[5]));
break;
#endif /* !defined(__GO32__) && !defined(_WIN32) */
{
/* Include the termination byte. */
int i = strlen (prog_argv[regs[5]]) + 1;
- regs[0] = sim_write (0, regs[6], prog_argv[regs[5]], i);
+ regs[0] = sim_write (0, regs[6], (void *) prog_argv[regs[5]], i);
}
else
regs[0] = -1;
return 0;
}
-static int
-div1 (R, iRn2, iRn1/*, T*/)
- int *R;
- int iRn1;
- int iRn2;
- /* int T;*/
+static void
+div1 (int *R, int iRn2, int iRn1/*, int T*/)
{
unsigned long tmp0;
unsigned char old_q, tmp1;
}
static void
-dmul (sign, rm, rn)
- int sign;
- unsigned int rm;
- unsigned int rn;
+dmul (int sign, unsigned int rm, unsigned int rn)
{
unsigned long RnL, RnH;
unsigned long RmL, RmH;
}
static void
-macw (regs, memory, n, m, endianw)
- int *regs;
- unsigned char *memory;
- int m, n;
- int endianw;
+macw (int *regs, unsigned char *memory, int n, int m, int endianw)
{
long tempm, tempn;
long prod, macl, sum;
}
static void
-macl (regs, memory, n, m)
- int *regs;
- unsigned char *memory;
- int m, n;
+macl (int *regs, unsigned char *memory, int n, int m)
{
long tempm, tempn;
long macl, mach;
};
/* Do extended displacement move instructions. */
-void
+static void
do_long_move_insn (int op, int disp12, int m, int n, int *thatlock)
{
int memstalls = 0;
}
/* Do binary logical bit-manipulation insns. */
-void
+static void
do_blog_insn (int imm, int addr, int binop,
unsigned char *memory, int maskb)
{
break;
}
}
-float
+
+static float
fsca_s (int in, double (*f) (double))
{
double rad = ldexp ((in & 0xffff), -15) * 3.141592653589793238462643383;
return abs (upper - result) >= abs (lower - result) ? upper : lower;
}
-float
+static float
fsrra_s (float in)
{
double result = 1. / sqrt (in);
pointed to by RS and RE -- for SETRC, they're not (see docs). */
static struct loop_bounds
-get_loop_bounds_ext (rs, re, memory, mem_end, maskw, endianw)
- int rs, re;
- unsigned char *memory, *mem_end;
- int maskw, endianw;
+get_loop_bounds_ext (int rs, int re, unsigned char *memory,
+ unsigned char *mem_end, int maskw, int endianw)
{
struct loop_bounds loop;
}
static struct loop_bounds
-get_loop_bounds (rs, re, memory, mem_end, maskw, endianw)
- int rs, re;
- unsigned char *memory, *mem_end;
- int maskw, endianw;
+get_loop_bounds (int rs, int re, unsigned char *memory, unsigned char *mem_end,
+ int maskw, int endianw)
{
struct loop_bounds loop;
significantly cut the start-up time when a large simulator memory is
required, because pages are only zeroed on demand. */
#ifdef MAP_ANONYMOUS
-void *
+static void *
mcalloc (size_t nmemb, size_t size)
{
void *page;
/* Set the memory size to the power of two provided. */
void
-sim_size (power)
- int power;
-
+sim_size (int power)
{
sim_memory_size = power;
}
static void
-init_dsp (abfd)
- struct bfd *abfd;
+init_dsp (struct bfd *abfd)
{
int was_dsp = target_dsp;
unsigned long mach = bfd_get_mach (abfd);
}
static void
-init_pointers ()
+init_pointers (void)
{
host_little_endian = 0;
* (char*) &host_little_endian = 1;
}
static void
-dump_profile ()
+dump_profile (void)
{
unsigned int minpc;
unsigned int maxpc;
}
static void
-gotcall (from, to)
- int from;
- int to;
+gotcall (int from, int to)
{
swapout (from);
swapout (to);
#define MMASKB ((saved_state.asregs.msize -1) & ~0)
int
-sim_stop (sd)
- SIM_DESC sd;
+sim_stop (SIM_DESC sd)
{
raise_exception (SIGINT);
return 1;
}
void
-sim_resume (sd, step, siggnal)
- SIM_DESC sd;
- int step, siggnal;
+sim_resume (SIM_DESC sd, int step, int siggnal)
{
register unsigned char *insn_ptr;
unsigned char *mem_end;
#endif
top:
if (tracing)
- fprintf (stderr, "PC: %08x, insn: %04x\n", PH2T (insn_ptr), iword);
+ fprintf (stderr, "PC: %08lx, insn: %04x\n",
+ (unsigned long) PH2T (insn_ptr), iword);
#include "code.c"
}
int
-sim_write (sd, addr, buffer, size)
- SIM_DESC sd;
- SIM_ADDR addr;
- const unsigned char *buffer;
- int size;
+sim_write (SIM_DESC sd, SIM_ADDR addr, const unsigned char *buffer, int size)
{
int i;
}
int
-sim_read (sd, addr, buffer, size)
- SIM_DESC sd;
- SIM_ADDR addr;
- unsigned char *buffer;
- int size;
+sim_read (SIM_DESC sd, SIM_ADDR addr, unsigned char *buffer, int size)
{
int i;
};
int
-sim_store_register (sd, rn, memory, length)
- SIM_DESC sd;
- int rn;
- unsigned char *memory;
- int length;
+sim_store_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
{
unsigned val;
}
int
-sim_fetch_register (sd, rn, memory, length)
- SIM_DESC sd;
- int rn;
- unsigned char *memory;
- int length;
+sim_fetch_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
{
int val;
}
int
-sim_trace (sd)
- SIM_DESC sd;
+sim_trace (SIM_DESC sd)
{
tracing = 1;
sim_resume (sd, 0, 0);
}
void
-sim_stop_reason (sd, reason, sigrc)
- SIM_DESC sd;
- enum sim_stop *reason;
- int *sigrc;
+sim_stop_reason (SIM_DESC sd, enum sim_stop *reason, int *sigrc)
{
/* The SH simulator uses SIGQUIT to indicate that the program has
exited, so we must check for it here and translate it to exit. */
}
void
-sim_info (sd, verbose)
- SIM_DESC sd;
- int verbose;
+sim_info (SIM_DESC sd, int verbose)
{
double timetaken =
(double) saved_state.asregs.ticks / (double) now_persec ();
}
void
-sim_set_profile (n)
- int n;
+sim_set_profile (int n)
{
saved_state.asregs.profile = n;
}
void
-sim_set_profile_size (n)
- int n;
+sim_set_profile_size (int n)
{
sim_profile_size = n;
}
SIM_DESC
-sim_open (kind, cb, abfd, argv)
- SIM_OPEN_KIND kind;
- host_callback *cb;
- struct bfd *abfd;
- char **argv;
+sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv)
{
char **p;
int endian_set = 0;
}
static void
-parse_and_set_memory_size (str)
- const char *str;
+parse_and_set_memory_size (const char *str)
{
int n;
}
void
-sim_close (sd, quitting)
- SIM_DESC sd;
- int quitting;
+sim_close (SIM_DESC sd, int quitting)
{
/* nothing to do */
}
SIM_RC
-sim_load (sd, prog, abfd, from_tty)
- SIM_DESC sd;
- const char *prog;
- bfd *abfd;
- int from_tty;
+sim_load (SIM_DESC sd, const char *prog, bfd *abfd, int from_tty)
{
extern bfd *sim_load_file (); /* ??? Don't know where this should live. */
bfd *prog_bfd;
}
SIM_RC
-sim_create_inferior (sd, prog_bfd, argv, env)
- SIM_DESC sd;
- struct bfd *prog_bfd;
- char **argv;
- char **env;
+sim_create_inferior (SIM_DESC sd, struct bfd *prog_bfd, char **argv, char **env)
{
/* Clear the registers. */
memset (&saved_state, 0,
}
void
-sim_do_command (sd, cmd)
- SIM_DESC sd;
- const char *cmd;
+sim_do_command (SIM_DESC sd, const char *cmd)
{
const char *sms_cmd = "set-memory-size";
int cmdsize;
}
void
-sim_set_callbacks (p)
- host_callback *p;
+sim_set_callbacks (host_callback *p)
{
callback = p;
}