public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] sim: sh: switch syscalls to common nltvals
@ 2021-04-19 3:21 Michael Frysinger
0 siblings, 0 replies; only message in thread
From: Michael Frysinger @ 2021-04-19 3:21 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b7c5246bbfad67b60a820db5e548e665171645ec
commit b7c5246bbfad67b60a820db5e548e665171645ec
Author: Mike Frysinger <vapier@gentoo.org>
Date: Sun Apr 18 22:43:06 2021 -0400
sim: sh: switch syscalls to common nltvals
Rather than hand duplicate the syscall table, switch to the common
nltvals framework. We have to tweak the constant names, but we get
everything else for free. I made sure the constants have the same
values before & after too :).
Diff:
---
sim/common/ChangeLog | 5 +++++
sim/common/gennltvals.py | 2 ++
sim/common/nltvals.def | 38 ++++++++++++++++++++++++++++++++++++++
sim/sh/ChangeLog | 7 +++++++
sim/sh/Makefile.in | 3 +++
sim/sh/interp.c | 45 ++++++++++++++++++++++-----------------------
sim/sh/syscall.h | 36 ------------------------------------
7 files changed, 77 insertions(+), 59 deletions(-)
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index f0827b283a6..20a425731f5 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,3 +1,8 @@
+2021-04-18 Mike Frysinger <vapier@gentoo.org>
+
+ * gennltvals.py (TARGET_DIRS, TARGETS): Add sh.
+ * nltvals.def: Regenerate.
+
2021-04-18 Mike Frysinger <vapier@gentoo.org>
* gennltvals.py (TARGETS): Add rx.
diff --git a/sim/common/gennltvals.py b/sim/common/gennltvals.py
index bf0aaa484ad..5831607a17c 100755
--- a/sim/common/gennltvals.py
+++ b/sim/common/gennltvals.py
@@ -51,6 +51,7 @@ TARGET_DIRS = {
'i960': 'libgloss/i960',
'mcore': 'libgloss/mcore',
'riscv': 'libgloss/riscv/machine',
+ 'sh': 'newlib/libc/sys/sh/sys',
'v850': 'libgloss/v850/sys',
}
TARGETS = {
@@ -71,6 +72,7 @@ TARGETS = {
'pru',
'riscv',
'rx',
+ 'sh',
'sparc',
'v850',
}
diff --git a/sim/common/nltvals.def b/sim/common/nltvals.def
index fbaee3abc64..3b890af0639 100644
--- a/sim/common/nltvals.def
+++ b/sim/common/nltvals.def
@@ -688,6 +688,44 @@
/* end rx sys target macros */
#endif
#endif
+#ifdef NL_TARGET_sh
+#ifdef sys_defs
+/* from syscall.h */
+/* begin sh sys target macros */
+ { "SYS_ARG", 24 },
+ { "SYS_argc", 172 },
+ { "SYS_argn", 174 },
+ { "SYS_argnlen", 173 },
+ { "SYS_chdir", 12 },
+ { "SYS_chmod", 15 },
+ { "SYS_chown", 16 },
+ { "SYS_close", 6 },
+ { "SYS_creat", 8 },
+ { "SYS_execv", 11 },
+ { "SYS_execve", 59 },
+ { "SYS_exit", 1 },
+ { "SYS_fork", 2 },
+ { "SYS_fstat", 22 },
+ { "SYS_ftruncate", 130 },
+ { "SYS_getpid", 20 },
+ { "SYS_isatty", 21 },
+ { "SYS_link", 9 },
+ { "SYS_lseek", 19 },
+ { "SYS_mknod", 14 },
+ { "SYS_open", 5 },
+ { "SYS_pipe", 42 },
+ { "SYS_read", 3 },
+ { "SYS_stat", 38 },
+ { "SYS_time", 23 },
+ { "SYS_truncate", 129 },
+ { "SYS_unlink", 10 },
+ { "SYS_utime", 201 },
+ { "SYS_wait", 202 },
+ { "SYS_wait4", 7 },
+ { "SYS_write", 4 },
+/* end sh sys target macros */
+#endif
+#endif
#ifdef NL_TARGET_sparc
#ifdef sys_defs
/* from syscall.h */
diff --git a/sim/sh/ChangeLog b/sim/sh/ChangeLog
index 1389261de16..984ff5e6321 100644
--- a/sim/sh/ChangeLog
+++ b/sim/sh/ChangeLog
@@ -1,3 +1,10 @@
+2021-04-18 Mike Frysinger <vapier@gentoo.org>
+
+ * Makefile.in (NL_TARGET): Define.
+ * interp.c: Change syscall.h include to targ-vals.h.
+ (trap): Add TARGET_ prefix to all SYS_ constants.
+ * syscall.h: Removed.
+
2021-04-18 Mike Frysinger <vapier@gentoo.org>
* configure: Regenerate.
diff --git a/sim/sh/Makefile.in b/sim/sh/Makefile.in
index 54f1e0ab94b..e92b7843dab 100644
--- a/sim/sh/Makefile.in
+++ b/sim/sh/Makefile.in
@@ -15,6 +15,9 @@
# 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 7b9dd521c87..2fafcfd6628 100644
--- a/sim/sh/interp.c
+++ b/sim/sh/interp.c
@@ -60,8 +60,7 @@
#include "sim-base.h"
#include "sim-options.h"
-/* This file is local - if newlib changes, then so should this. */
-#include "syscall.h"
+#include "targ-vals.h"
#include <math.h>
@@ -887,21 +886,21 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
{
#if !defined(__GO32__) && !defined(_WIN32)
- case SYS_fork:
+ case TARGET_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 SYS_execve:
+ case TARGET_SYS_execve:
regs[0] = execve (ptr (regs[5]), (char **) ptr (regs[6]),
(char **) ptr (regs[7]));
break;
- case SYS_execv:
+ case TARGET_SYS_execv:
regs[0] = execve (ptr (regs[5]), (char **) ptr (regs[6]), 0);
break;
#endif
- case SYS_pipe:
+ case TARGET_SYS_pipe:
{
regs[0] = (BUSERROR (regs[5], maskl)
? -EINVAL
@@ -909,18 +908,18 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
}
break;
- case SYS_wait:
+ case TARGET_SYS_wait:
regs[0] = wait ((int *) ptr (regs[5]));
break;
#endif /* !defined(__GO32__) && !defined(_WIN32) */
- case SYS_read:
+ case TARGET_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 SYS_write:
+ case TARGET_SYS_write:
strnswap (regs[6], regs[7]);
if (regs[5] == 1)
regs[0] = (int) callback->write_stdout (callback,
@@ -930,13 +929,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 SYS_lseek:
+ case TARGET_SYS_lseek:
regs[0] = callback->lseek (callback,regs[5], regs[6], regs[7]);
break;
- case SYS_close:
+ case TARGET_SYS_close:
regs[0] = callback->close (callback,regs[5]);
break;
- case SYS_open:
+ case TARGET_SYS_open:
{
int len = strswaplen (regs[5]);
strnswap (regs[5], len);
@@ -944,13 +943,13 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
strnswap (regs[5], len);
break;
}
- case SYS_exit:
+ case TARGET_SYS_exit:
/* EXIT - caller can look in r5 to work out the reason */
raise_exception (SIGQUIT);
regs[0] = regs[5];
break;
- case SYS_stat: /* added at hmsi */
+ case TARGET_SYS_stat: /* added at hmsi */
/* stat system call */
{
struct stat host_stat;
@@ -999,7 +998,7 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
break;
#ifndef _WIN32
- case SYS_chown:
+ case TARGET_SYS_chown:
{
int len = strswaplen (regs[5]);
@@ -1009,7 +1008,7 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
break;
}
#endif /* _WIN32 */
- case SYS_chmod:
+ case TARGET_SYS_chmod:
{
int len = strswaplen (regs[5]);
@@ -1018,7 +1017,7 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
strnswap (regs[5], len);
break;
}
- case SYS_utime:
+ case TARGET_SYS_utime:
{
/* Cast the second argument to void *, to avoid type mismatch
if a prototype is present. */
@@ -1029,16 +1028,16 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
strnswap (regs[5], len);
break;
}
- case SYS_argc:
+ case TARGET_SYS_argc:
regs[0] = countargv (prog_argv);
break;
- case SYS_argnlen:
+ case TARGET_SYS_argnlen:
if (regs[5] < countargv (prog_argv))
regs[0] = strlen (prog_argv[regs[5]]);
else
regs[0] = -1;
break;
- case SYS_argn:
+ case TARGET_SYS_argn:
if (regs[5] < countargv (prog_argv))
{
/* Include the termination byte. */
@@ -1048,13 +1047,13 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
else
regs[0] = -1;
break;
- case SYS_time:
+ case TARGET_SYS_time:
regs[0] = get_now ();
break;
- case SYS_ftruncate:
+ case TARGET_SYS_ftruncate:
regs[0] = callback->ftruncate (callback, regs[5], regs[6]);
break;
- case SYS_truncate:
+ case TARGET_SYS_truncate:
{
int len = strswaplen (regs[5]);
strnswap (regs[5], len);
diff --git a/sim/sh/syscall.h b/sim/sh/syscall.h
deleted file mode 100644
index aebce2ce26d..00000000000
--- a/sim/sh/syscall.h
+++ /dev/null
@@ -1,36 +0,0 @@
-
-/* !!! DANGER !!!
- This was copied from newlib. */
-
-
-#define SYS_exit 1
-#define SYS_fork 2
-#define SYS_read 3
-#define SYS_write 4
-#define SYS_open 5
-#define SYS_close 6
-#define SYS_wait4 7
-#define SYS_creat 8
-#define SYS_link 9
-#define SYS_unlink 10
-#define SYS_execv 11
-#define SYS_chdir 12
-#define SYS_mknod 14
-#define SYS_chmod 15
-#define SYS_chown 16
-#define SYS_lseek 19
-#define SYS_getpid 20
-#define SYS_isatty 21
-#define SYS_fstat 22
-#define SYS_time 23
-#define SYS_ARG 24
-#define SYS_stat 38
-#define SYS_pipe 42
-#define SYS_execve 59
-#define SYS_truncate 129
-#define SYS_ftruncate 130
-#define SYS_argc 172
-#define SYS_argnlen 173
-#define SYS_argn 174
-#define SYS_utime 201 /* not really a system call */
-#define SYS_wait 202 /* nor is this */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-04-19 3:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-19 3:21 [binutils-gdb] sim: sh: switch syscalls to common nltvals Michael Frysinger
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).