From: Mike Frysinger <vapier@gentoo.org>
To: gdb-patches@sourceware.org
Subject: [PATCH 3/9] sim: v850: switch to new target-newlib-syscall
Date: Sun, 28 Nov 2021 03:43:52 -0500 [thread overview]
Message-ID: <20211128084358.29302-3-vapier@gentoo.org> (raw)
In-Reply-To: <20211128084358.29302-1-vapier@gentoo.org>
Use the new target-newlib-syscall module. This is needed to merge all
the architectures into a single build, and v850 has a custom syscall
table for its newlib/libgloss port.
This allows cleaning up the syscall ifdef logic. We know these will
always exist now.
---
sim/v850/Makefile.in | 2 -
sim/v850/interp.c | 3 ++
sim/v850/simops.c | 88 ++++++++++++--------------------------------
3 files changed, 26 insertions(+), 67 deletions(-)
diff --git a/sim/v850/Makefile.in b/sim/v850/Makefile.in
index 07014b8afb8c..92b583678d73 100644
--- a/sim/v850/Makefile.in
+++ b/sim/v850/Makefile.in
@@ -31,6 +31,4 @@ SIM_EXTRA_DEPS = v850_sim.h sim-main.h
SIM_EXTRA_CFLAGS = \
-DDEBUG
-NL_TARGET = -DNL_TARGET_v850
-
## COMMON_POST_CONFIG_FRAG
diff --git a/sim/v850/interp.c b/sim/v850/interp.c
index 0d3136580551..f450679aaf22 100644
--- a/sim/v850/interp.c
+++ b/sim/v850/interp.c
@@ -12,6 +12,8 @@
#include "bfd.h"
+#include "target-newlib-syscall.h"
+
static const char * get_insn_name (sim_cpu *, int);
/* For compatibility. */
@@ -199,6 +201,7 @@ sim_open (SIM_OPEN_KIND kind,
/* Set default options before parsing user options. */
current_target_byte_order = BFD_ENDIAN_LITTLE;
+ cb->syscall_map = cb_v850_syscall_map;
/* The cpu data is kept in a separately allocated chunk of memory. */
if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
diff --git a/sim/v850/simops.c b/sim/v850/simops.c
index 6a111044f652..1178721a9759 100644
--- a/sim/v850/simops.c
+++ b/sim/v850/simops.c
@@ -18,8 +18,6 @@
#include <stdlib.h>
#include <string.h>
-#include "targ-vals.h"
-
#include "libiberty.h"
#include <errno.h>
@@ -29,6 +27,8 @@
#include <sys/time.h>
#endif
+#include "target-newlib-syscall.h"
+
/* This is an array of the bit positions of registers r20 .. r31 in
that order in a prepare/dispose instruction. */
int type1_regs[12] = { 27, 26, 25, 24, 31, 30, 29, 28, 23, 22, 0, 21 };
@@ -1626,17 +1626,14 @@ OP_10007E0 (void)
{
#ifdef HAVE_FORK
-#ifdef TARGET_SYS_fork
- case TARGET_SYS_fork:
+ case TARGET_NEWLIB_V850_SYS_fork:
RETVAL = fork ();
RETERR = errno;
break;
#endif
-#endif
#ifdef HAVE_EXECVE
-#ifdef TARGET_SYS_execv
- case TARGET_SYS_execve:
+ case TARGET_NEWLIB_V850_SYS_execve:
{
char *path = fetch_str (simulator, PARM1);
char **argv = fetch_argv (simulator, PARM2);
@@ -1649,11 +1646,9 @@ OP_10007E0 (void)
break;
}
#endif
-#endif
#if HAVE_EXECV
-#ifdef TARGET_SYS_execv
- case TARGET_SYS_execv:
+ case TARGET_NEWLIB_V850_SYS_execv:
{
char *path = fetch_str (simulator, PARM1);
char **argv = fetch_argv (simulator, PARM2);
@@ -1664,11 +1659,9 @@ OP_10007E0 (void)
break;
}
#endif
-#endif
#if 0
-#ifdef TARGET_SYS_pipe
- case TARGET_SYS_pipe:
+ case TARGET_NEWLIB_V850_SYS_pipe:
{
reg_t buf;
int host_fd[2];
@@ -1682,11 +1675,9 @@ OP_10007E0 (void)
}
break;
#endif
-#endif
#if 0
-#ifdef TARGET_SYS_wait
- case TARGET_SYS_wait:
+ case TARGET_NEWLIB_V850_SYS_wait:
{
int status;
@@ -1696,10 +1687,8 @@ OP_10007E0 (void)
}
break;
#endif
-#endif
-#ifdef TARGET_SYS_read
- case TARGET_SYS_read:
+ case TARGET_NEWLIB_V850_SYS_read:
{
char *buf = zalloc (PARM3);
RETVAL = sim_io_read (simulator, PARM1, buf, PARM3);
@@ -1709,10 +1698,8 @@ OP_10007E0 (void)
RETERR = sim_io_get_errno (simulator);
break;
}
-#endif
-#ifdef TARGET_SYS_write
- case TARGET_SYS_write:
+ case TARGET_NEWLIB_V850_SYS_write:
{
char *buf = zalloc (PARM3);
sim_read (simulator, PARM2, (unsigned char *) buf, PARM3);
@@ -1725,26 +1712,20 @@ OP_10007E0 (void)
RETERR = sim_io_get_errno (simulator);
break;
}
-#endif
-#ifdef TARGET_SYS_lseek
- case TARGET_SYS_lseek:
+ case TARGET_NEWLIB_V850_SYS_lseek:
RETVAL = sim_io_lseek (simulator, PARM1, PARM2, PARM3);
if ((int) RETVAL < 0)
RETERR = sim_io_get_errno (simulator);
break;
-#endif
-#ifdef TARGET_SYS_close
- case TARGET_SYS_close:
+ case TARGET_NEWLIB_V850_SYS_close:
RETVAL = sim_io_close (simulator, PARM1);
if ((int) RETVAL < 0)
RETERR = sim_io_get_errno (simulator);
break;
-#endif
-#ifdef TARGET_SYS_open
- case TARGET_SYS_open:
+ case TARGET_NEWLIB_V850_SYS_open:
{
char *buf = fetch_str (simulator, PARM1);
RETVAL = sim_io_open (simulator, buf, PARM2);
@@ -1753,10 +1734,8 @@ OP_10007E0 (void)
RETERR = sim_io_get_errno (simulator);
break;
}
-#endif
-#ifdef TARGET_SYS_exit
- case TARGET_SYS_exit:
+ case TARGET_NEWLIB_V850_SYS_exit:
if ((PARM1 & 0xffff0000) == 0xdead0000 && (PARM1 & 0xffff) != 0)
/* get signal encoded by kill */
sim_engine_halt (simulator, STATE_CPU (simulator, 0), NULL, PC,
@@ -1770,10 +1749,8 @@ OP_10007E0 (void)
sim_engine_halt (simulator, STATE_CPU (simulator, 0), NULL, PC,
sim_exited, PARM1);
break;
-#endif
-#ifdef TARGET_SYS_stat
- case TARGET_SYS_stat: /* added at hmsi */
+ case TARGET_NEWLIB_V850_SYS_stat: /* added at hmsi */
/* stat system call */
{
struct stat host_stat;
@@ -1802,10 +1779,8 @@ OP_10007E0 (void)
RETERR = sim_io_get_errno (simulator);
}
break;
-#endif
-#ifdef TARGET_SYS_fstat
- case TARGET_SYS_fstat:
+ case TARGET_NEWLIB_V850_SYS_fstat:
/* fstat system call */
{
struct stat host_stat;
@@ -1832,10 +1807,8 @@ OP_10007E0 (void)
RETERR = sim_io_get_errno (simulator);
}
break;
-#endif
-#ifdef TARGET_SYS_rename
- case TARGET_SYS_rename:
+ case TARGET_NEWLIB_V850_SYS_rename:
{
char *oldpath = fetch_str (simulator, PARM1);
char *newpath = fetch_str (simulator, PARM2);
@@ -1846,10 +1819,8 @@ OP_10007E0 (void)
RETERR = sim_io_get_errno (simulator);
}
break;
-#endif
-#ifdef TARGET_SYS_unlink
- case TARGET_SYS_unlink:
+ case TARGET_NEWLIB_V850_SYS_unlink:
{
char *path = fetch_str (simulator, PARM1);
RETVAL = sim_io_unlink (simulator, path);
@@ -1858,10 +1829,8 @@ OP_10007E0 (void)
RETERR = sim_io_get_errno (simulator);
}
break;
-#endif
-#ifdef TARGET_SYS_chown
- case TARGET_SYS_chown:
+ case TARGET_NEWLIB_V850_SYS_chown:
{
char *path = fetch_str (simulator, PARM1);
RETVAL = chown (path, PARM2, PARM3);
@@ -1869,11 +1838,9 @@ OP_10007E0 (void)
RETERR = errno;
}
break;
-#endif
#if HAVE_CHMOD
-#ifdef TARGET_SYS_chmod
- case TARGET_SYS_chmod:
+ case TARGET_NEWLIB_V850_SYS_chmod:
{
char *path = fetch_str (simulator, PARM1);
RETVAL = chmod (path, PARM2);
@@ -1882,11 +1849,9 @@ OP_10007E0 (void)
}
break;
#endif
-#endif
-#ifdef TARGET_SYS_time
#if HAVE_TIME
- case TARGET_SYS_time:
+ case TARGET_NEWLIB_V850_SYS_time:
{
time_t now;
RETVAL = time (&now);
@@ -1895,11 +1860,9 @@ OP_10007E0 (void)
}
break;
#endif
-#endif
#if !defined(__GO32__) && !defined(_WIN32)
-#ifdef TARGET_SYS_times
- case TARGET_SYS_times:
+ case TARGET_NEWLIB_V850_SYS_times:
{
struct tms tms;
RETVAL = times (&tms);
@@ -1911,11 +1874,9 @@ OP_10007E0 (void)
break;
}
#endif
-#endif
-#ifdef TARGET_SYS_gettimeofday
#if !defined(__GO32__) && !defined(_WIN32)
- case TARGET_SYS_gettimeofday:
+ case TARGET_NEWLIB_V850_SYS_gettimeofday:
{
struct timeval t;
struct timezone tz;
@@ -1928,11 +1889,9 @@ OP_10007E0 (void)
break;
}
#endif
-#endif
-#ifdef TARGET_SYS_utime
#if HAVE_UTIME
- case TARGET_SYS_utime:
+ case TARGET_NEWLIB_V850_SYS_utime:
{
/* Cast the second argument to void *, to avoid type mismatch
if a prototype is present. */
@@ -1940,7 +1899,6 @@ OP_10007E0 (void)
/* RETVAL = utime (path, (void *) MEMPTR (PARM2)); */
}
break;
-#endif
#endif
default:
--
2.33.0
next prev parent reply other threads:[~2021-11-28 8:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-28 8:43 [PATCH 1/9] sim: nltvals: pull target syscalls out into a dedicated source file Mike Frysinger
2021-11-28 8:43 ` [PATCH 2/9] sim: iq2000/lm32/m32c/moxie/rx: switch to new target-newlib-syscall.h Mike Frysinger
2021-11-28 8:43 ` Mike Frysinger [this message]
2021-11-28 8:43 ` [PATCH 4/9] sim: sh: switch to new target-newlib-syscall Mike Frysinger
2021-11-28 8:43 ` [PATCH 5/9] sim: d10v: " Mike Frysinger
2021-11-28 8:43 ` [PATCH 6/9] sim: cr16: " Mike Frysinger
2021-11-28 8:43 ` [PATCH 7/9] sim: riscv: " Mike Frysinger
2021-11-28 8:43 ` [PATCH 8/9] sim: mcore: " Mike Frysinger
2021-11-28 8:43 ` [PATCH 9/9] sim: drop unused gentmap & nltvals.def logic Mike Frysinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211128084358.29302-3-vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).