public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: gdb-patches@sourceware.org
Subject: [PATCH 4/9] sim: sh: switch to new target-newlib-syscall
Date: Sun, 28 Nov 2021 03:43:53 -0500	[thread overview]
Message-ID: <20211128084358.29302-4-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 sh has a custom syscall
table for its newlib/libgloss port.
---
 sim/sh/Makefile.in |  3 ---
 sim/sh/interp.c    | 45 +++++++++++++++++++++++----------------------
 2 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/sim/sh/Makefile.in b/sim/sh/Makefile.in
index e58cd48f1ae2..3435f403ab86 100644
--- a/sim/sh/Makefile.in
+++ b/sim/sh/Makefile.in
@@ -15,9 +15,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# This selects the newlib/libgloss syscall definitions.
-NL_TARGET = -DNL_TARGET_sh
-
 ## COMMON_PRE_CONFIG_FRAG
 
 SIM_OBJS = \
diff --git a/sim/sh/interp.c b/sim/sh/interp.c
index 1b2b09f95100..fb92d9f4480a 100644
--- a/sim/sh/interp.c
+++ b/sim/sh/interp.c
@@ -61,7 +61,7 @@
 #include "sim-base.h"
 #include "sim-options.h"
 
-#include "targ-vals.h"
+#include "target-newlib-syscall.h"
 
 #include <math.h>
 
@@ -888,21 +888,21 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
 	  {
 
 #if !defined(__GO32__) && !defined(_WIN32)
-	  case TARGET_SYS_fork:
+	  case TARGET_NEWLIB_SH_SYS_fork:
 	    regs[0] = fork ();
 	    break;
 /* This would work only if endianness matched between host and target.
    Besides, it's quite dangerous.  */
 #if 0
-	  case TARGET_SYS_execve:
+	  case TARGET_NEWLIB_SH_SYS_execve:
 	    regs[0] = execve (ptr (regs[5]), (char **) ptr (regs[6]), 
 			      (char **) ptr (regs[7]));
 	    break;
-	  case TARGET_SYS_execv:
+	  case TARGET_NEWLIB_SH_SYS_execv:
 	    regs[0] = execve (ptr (regs[5]), (char **) ptr (regs[6]), 0);
 	    break;
 #endif
-	  case TARGET_SYS_pipe:
+	  case TARGET_NEWLIB_SH_SYS_pipe:
 	    {
 	      regs[0] = (BUSERROR (regs[5], maskl)
 			 ? -EINVAL
@@ -910,18 +910,18 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
 	    }
 	    break;
 
-	  case TARGET_SYS_wait:
+	  case TARGET_NEWLIB_SH_SYS_wait:
 	    regs[0] = wait ((int *) ptr (regs[5]));
 	    break;
 #endif /* !defined(__GO32__) && !defined(_WIN32) */
 
-	  case TARGET_SYS_read:
+	  case TARGET_NEWLIB_SH_SYS_read:
 	    strnswap (regs[6], regs[7]);
 	    regs[0]
 	      = callback->read (callback, regs[5], ptr (regs[6]), regs[7]);
 	    strnswap (regs[6], regs[7]);
 	    break;
-	  case TARGET_SYS_write:
+	  case TARGET_NEWLIB_SH_SYS_write:
 	    strnswap (regs[6], regs[7]);
 	    if (regs[5] == 1)
 	      regs[0] = (int) callback->write_stdout (callback, 
@@ -931,13 +931,13 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
 					       ptr (regs[6]), regs[7]);
 	    strnswap (regs[6], regs[7]);
 	    break;
-	  case TARGET_SYS_lseek:
+	  case TARGET_NEWLIB_SH_SYS_lseek:
 	    regs[0] = callback->lseek (callback,regs[5], regs[6], regs[7]);
 	    break;
-	  case TARGET_SYS_close:
+	  case TARGET_NEWLIB_SH_SYS_close:
 	    regs[0] = callback->close (callback,regs[5]);
 	    break;
-	  case TARGET_SYS_open:
+	  case TARGET_NEWLIB_SH_SYS_open:
 	    {
 	      int len = strswaplen (regs[5]);
 	      strnswap (regs[5], len);
@@ -945,13 +945,13 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
 	      strnswap (regs[5], len);
 	      break;
 	    }
-	  case TARGET_SYS_exit:
+	  case TARGET_NEWLIB_SH_SYS_exit:
 	    /* EXIT - caller can look in r5 to work out the reason */
 	    raise_exception (SIGQUIT);
 	    regs[0] = regs[5];
 	    break;
 
-	  case TARGET_SYS_stat:	/* added at hmsi */
+	  case TARGET_NEWLIB_SH_SYS_stat:	/* added at hmsi */
 	    /* stat system call */
 	    {
 	      struct stat host_stat;
@@ -1000,7 +1000,7 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
 	    break;
 
 #ifndef _WIN32
-	  case TARGET_SYS_chown:
+	  case TARGET_NEWLIB_SH_SYS_chown:
 	    {
 	      int len = strswaplen (regs[5]);
 
@@ -1010,7 +1010,7 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
 	      break;
 	    }
 #endif /* _WIN32 */
-	  case TARGET_SYS_chmod:
+	  case TARGET_NEWLIB_SH_SYS_chmod:
 	    {
 	      int len = strswaplen (regs[5]);
 
@@ -1019,7 +1019,7 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
 	      strnswap (regs[5], len);
 	      break;
 	    }
-	  case TARGET_SYS_utime:
+	  case TARGET_NEWLIB_SH_SYS_utime:
 	    {
 	      /* Cast the second argument to void *, to avoid type mismatch
 		 if a prototype is present.  */
@@ -1035,16 +1035,16 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
 	      strnswap (regs[5], len);
 	      break;
 	    }
-	  case TARGET_SYS_argc:
+	  case TARGET_NEWLIB_SH_SYS_argc:
 	    regs[0] = countargv (prog_argv);
 	    break;
-	  case TARGET_SYS_argnlen:
+	  case TARGET_NEWLIB_SH_SYS_argnlen:
 	    if (regs[5] < countargv (prog_argv))
 	      regs[0] = strlen (prog_argv[regs[5]]);
 	    else
 	      regs[0] = -1;
 	    break;
-	  case TARGET_SYS_argn:
+	  case TARGET_NEWLIB_SH_SYS_argn:
 	    if (regs[5] < countargv (prog_argv))
 	      {
 		/* Include the termination byte.  */
@@ -1054,13 +1054,13 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
 	    else
 	      regs[0] = -1;
 	    break;
-	  case TARGET_SYS_time:
+	  case TARGET_NEWLIB_SH_SYS_time:
 	    regs[0] = get_now ();
 	    break;
-	  case TARGET_SYS_ftruncate:
+	  case TARGET_NEWLIB_SH_SYS_ftruncate:
 	    regs[0] = callback->ftruncate (callback, regs[5], regs[6]);
 	    break;
-	  case TARGET_SYS_truncate:
+	  case TARGET_NEWLIB_SH_SYS_truncate:
 	    {
 	      int len = strswaplen (regs[5]);
 	      strnswap (regs[5], len);
@@ -2345,6 +2345,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
 
   /* Set default options before parsing user options.  */
   current_alignment = STRICT_ALIGNMENT;
+  cb->syscall_map = cb_sh_syscall_map;
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
   if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
-- 
2.33.0


  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 ` [PATCH 3/9] sim: v850: switch to new target-newlib-syscall Mike Frysinger
2021-11-28  8:43 ` Mike Frysinger [this message]
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-4-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).