public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/9] sim: nltvals: pull target syscalls out into a dedicated source file
@ 2021-11-28  8:43 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
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Mike Frysinger @ 2021-11-28  8:43 UTC (permalink / raw)
  To: gdb-patches

Like we just did for pulling out the errno map, pull out the syscall
maps into a dedicated common file.  Most newlib ports are using the
same syscall map, but not all, which means we have to do a bit more
work to migrate.

This commit adds the maps and switches the ports using the common
default syscall table over to it.  Ports using unique syscall tables
are still using the old targ-map.c logic.

Switching common ports over is easy by checking NL_TARGET, but the
ppc code needs a bit more cleanup here hence its larger diff.
---
 sim/Makefile.am                    |   5 +-
 sim/Makefile.in                    |  19 +
 sim/README-HACKING                 |  23 +-
 sim/common/Make-common.in          |  15 +-
 sim/common/gennltvals.py           |  77 +++-
 sim/common/local.mk                |   1 +
 sim/common/target-newlib-syscall.c | 634 +++++++++++++++++++++++++++++
 sim/common/target-newlib-syscall.h | 237 +++++++++++
 sim/ppc/Makefile.in                |  36 +-
 9 files changed, 986 insertions(+), 61 deletions(-)
 create mode 100644 sim/common/target-newlib-syscall.c
 create mode 100644 sim/common/target-newlib-syscall.h

diff --git a/sim/Makefile.am b/sim/Makefile.am
index 909bec00553f..c3e7e767c47b 100644
--- a/sim/Makefile.am
+++ b/sim/Makefile.am
@@ -49,12 +49,9 @@ LINK_FOR_BUILD = $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@
 # into any subdirs.
 SIM_ALL_RECURSIVE_DEPS =
 
-# Generate nltvals.def for newlib/libgloss using devo and build tree.
+# Generate target constants for newlib/libgloss from its source tree.
 # This file is shipped with distributions so we build in the source dir.
 # Use `make nltvals' to rebuild.
-# Note: If gdb releases begin to contain target header files (not a good idea,
-# but if they did ...), nltvals.def coud be generated at build time.
-# An alternative is to slurp in the tables at runtime.
 .PHONY: nltvals
 nltvals:
 	$(srccom)/gennltvals.py --cpp "$(CPP)"
diff --git a/sim/Makefile.in b/sim/Makefile.in
index 1dae0a482fb9..2a871e50db8f 100644
--- a/sim/Makefile.in
+++ b/sim/Makefile.in
@@ -647,6 +647,7 @@ am_common_libcommon_a_OBJECTS =  \
 	common/common_libcommon_a-target-newlib-errno.$(OBJEXT) \
 	common/common_libcommon_a-target-newlib-open.$(OBJEXT) \
 	common/common_libcommon_a-target-newlib-signal.$(OBJEXT) \
+	common/common_libcommon_a-target-newlib-syscall.$(OBJEXT) \
 	common/common_libcommon_a-version.$(OBJEXT)
 common_libcommon_a_OBJECTS = $(am_common_libcommon_a_OBJECTS)
 igen_libigen_a_AR = $(AR) $(ARFLAGS)
@@ -1286,6 +1287,7 @@ common_libcommon_a_SOURCES = \
 	common/target-newlib-errno.c \
 	common/target-newlib-open.c \
 	common/target-newlib-signal.c \
+	common/target-newlib-syscall.c \
 	common/version.c
 
 
@@ -1622,6 +1624,8 @@ common/common_libcommon_a-target-newlib-open.$(OBJEXT):  \
 	common/$(am__dirstamp) common/$(DEPDIR)/$(am__dirstamp)
 common/common_libcommon_a-target-newlib-signal.$(OBJEXT):  \
 	common/$(am__dirstamp) common/$(DEPDIR)/$(am__dirstamp)
+common/common_libcommon_a-target-newlib-syscall.$(OBJEXT):  \
+	common/$(am__dirstamp) common/$(DEPDIR)/$(am__dirstamp)
 common/common_libcommon_a-version.$(OBJEXT): common/$(am__dirstamp) \
 	common/$(DEPDIR)/$(am__dirstamp)
 
@@ -1812,6 +1816,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@common/$(DEPDIR)/common_libcommon_a-target-newlib-errno.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@common/$(DEPDIR)/common_libcommon_a-target-newlib-open.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@common/$(DEPDIR)/common_libcommon_a-target-newlib-signal.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@common/$(DEPDIR)/common_libcommon_a-target-newlib-syscall.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@common/$(DEPDIR)/common_libcommon_a-version.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@cr16/$(DEPDIR)/gencode.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@d10v/$(DEPDIR)/gencode.Po@am__quote@
@@ -1951,6 +1956,20 @@ common/common_libcommon_a-target-newlib-signal.obj: common/target-newlib-signal.
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(common_libcommon_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o common/common_libcommon_a-target-newlib-signal.obj `if test -f 'common/target-newlib-signal.c'; then $(CYGPATH_W) 'common/target-newlib-signal.c'; else $(CYGPATH_W) '$(srcdir)/common/target-newlib-signal.c'; fi`
 
+common/common_libcommon_a-target-newlib-syscall.o: common/target-newlib-syscall.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(common_libcommon_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT common/common_libcommon_a-target-newlib-syscall.o -MD -MP -MF common/$(DEPDIR)/common_libcommon_a-target-newlib-syscall.Tpo -c -o common/common_libcommon_a-target-newlib-syscall.o `test -f 'common/target-newlib-syscall.c' || echo '$(srcdir)/'`common/target-newlib-syscall.c
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) common/$(DEPDIR)/common_libcommon_a-target-newlib-syscall.Tpo common/$(DEPDIR)/common_libcommon_a-target-newlib-syscall.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='common/target-newlib-syscall.c' object='common/common_libcommon_a-target-newlib-syscall.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(common_libcommon_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o common/common_libcommon_a-target-newlib-syscall.o `test -f 'common/target-newlib-syscall.c' || echo '$(srcdir)/'`common/target-newlib-syscall.c
+
+common/common_libcommon_a-target-newlib-syscall.obj: common/target-newlib-syscall.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(common_libcommon_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT common/common_libcommon_a-target-newlib-syscall.obj -MD -MP -MF common/$(DEPDIR)/common_libcommon_a-target-newlib-syscall.Tpo -c -o common/common_libcommon_a-target-newlib-syscall.obj `if test -f 'common/target-newlib-syscall.c'; then $(CYGPATH_W) 'common/target-newlib-syscall.c'; else $(CYGPATH_W) '$(srcdir)/common/target-newlib-syscall.c'; fi`
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) common/$(DEPDIR)/common_libcommon_a-target-newlib-syscall.Tpo common/$(DEPDIR)/common_libcommon_a-target-newlib-syscall.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='common/target-newlib-syscall.c' object='common/common_libcommon_a-target-newlib-syscall.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(common_libcommon_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o common/common_libcommon_a-target-newlib-syscall.obj `if test -f 'common/target-newlib-syscall.c'; then $(CYGPATH_W) 'common/target-newlib-syscall.c'; else $(CYGPATH_W) '$(srcdir)/common/target-newlib-syscall.c'; fi`
+
 common/common_libcommon_a-version.o: common/version.c
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(common_libcommon_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT common/common_libcommon_a-version.o -MD -MP -MF common/$(DEPDIR)/common_libcommon_a-version.Tpo -c -o common/common_libcommon_a-version.o `test -f 'common/version.c' || echo '$(srcdir)/'`common/version.c
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) common/$(DEPDIR)/common_libcommon_a-version.Tpo common/$(DEPDIR)/common_libcommon_a-version.Po
diff --git a/sim/README-HACKING b/sim/README-HACKING
index 9bb705e655eb..38915bf3bb94 100644
--- a/sim/README-HACKING
+++ b/sim/README-HACKING
@@ -20,10 +20,7 @@ The common directory contains:
 - common Makefile fragment and configury (e.g. Make-common.in, aclocal.m4).
 
 In addition "common" contains portions of the system call support
-(e.g. callback.c, nltvals.def).
-
-Even though no files are built in this directory, it is still configured
-so support for regenerating nltvals.def is present.
+(e.g. callback.c, target-newlib-*.c).
 \f
 Common Makefile Support
 =======================
@@ -161,8 +158,8 @@ internal state pretty printed from gdb.
 
 FIXME: This can obviously be made more elaborate.  As needed it will be.
 \f
-Rebuilding nltvals.def
-======================
+Rebuilding target-newlib-* files
+================================
 
 Checkout a copy of the SIM and LIBGLOSS modules (Unless you've already
 got one to hand):
@@ -191,17 +188,9 @@ all set!  If the target has a custom syscall table, you need to declare it:
 		Add your new processor target (you'll need to grub
 		around to find where your syscall.h lives).
 
-	devo/sim/<processor>/Makefile.in
-
-		Add the definition:
-
-			``NL_TARGET = -DNL_TARGET_d10v''
-
-		just before the line COMMON_POST_CONFIG_FRAG.
-
 	devo/sim/<processor>/*.[ch]
 
-		Include targ-vals.h instead of syscall.h.
+		Include target-newlib-syscall.h instead of syscall.h.
 \f
 Tracing
 =======
@@ -335,8 +324,8 @@ only store the error code when the result is an error.
 
 Keep in mind that the CB_SYS_xxx defines are normalized values with no real
 meaning with respect to the target.  They provide a unique map on the host so
-that it can parse things sanely.  For libgloss, the common/nltvals.def file
-creates the target's system call numbers to the CB_SYS_xxx values.
+that it can parse things sanely.  For libgloss, the common/target-newlib-syscall
+file contains the target's system call numbers to the CB_SYS_xxx values.
 
 To simulate other userspace targets, you really only need to update the maps
 pointers that are part of the callback interface.  So create CB_TARGET_DEFS_MAP
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index 9be682e61173..f834edbec8a8 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -238,7 +238,14 @@ COMMON_OBJS_NAMES = \
 	version.o
 COMMON_OBJS = $(COMMON_OBJS_NAMES:%=../common/common_libcommon_a-%)
 
-LIB_OBJS = modules.o syscall.o targ-map.o $(COMMON_OBJS) $(SIM_OBJS)
+LIB_OBJS = modules.o syscall.o $(COMMON_OBJS) $(SIM_OBJS)
+
+# TODO: Migrate everyone to target-newlib-syscall.o.
+ifeq ($(NL_TARGET),)
+COMMON_OBJS_NAMES += target-newlib-syscall.o
+else
+LIB_OBJS += targ-map.o
+endif
 
 COMPILE_FOR_BUILD = $(CC_FOR_BUILD) $(BUILD_CFLAGS)
 LINK_FOR_BUILD = $(CC_FOR_BUILD) $(BUILD_CFLAGS) $(LDFLAGS_FOR_BUILD) -o $@
@@ -275,9 +282,11 @@ stamp-tvals: gentmap
 	$(ECHO_STAMP) targ-vals.h
 	$(SILENCE) ./gentmap -h >tmp-tvals.h
 	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-tvals.h targ-vals.h
+ifneq ($(NL_TARGET),)
 	$(ECHO_STAMP) targ-tmap.c
 	$(SILENCE) ./gentmap -c >tmp-tmap.c
 	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-tmap.c targ-map.c
+endif
 	$(SILENCE) touch $@
 
 #
@@ -405,8 +414,10 @@ generated_files = \
 	$(SIM_EXTRA_DEPS) \
 	hw-config.h \
 	modules.c \
-	targ-map.c \
 	targ-vals.h
+ifneq ($(NL_TARGET),)
+generated_files += targ-map.c
+endif
 
 # Ensure that generated files are created early.  Use order-only
 # dependencies if available.  They require GNU make 3.80 or newer,
diff --git a/sim/common/gennltvals.py b/sim/common/gennltvals.py
index 66ee9c567536..1e98691cb3d5 100755
--- a/sim/common/gennltvals.py
+++ b/sim/common/gennltvals.py
@@ -177,15 +177,80 @@ def gen_common(output_dir: Path, output: TextIO, newlib: Path, cpp: str):
              ('fcntl.h', 'sys/fcntl.h', 'sys/_default_fcntl.h'), r'O_[A-Z0-9]*')
 
 
-def gen_targets(output_dir: Path, output: TextIO, newlib: Path, cpp: str):
-    """Generate the target-specific lists."""
+def gen_target_syscall(output_dir: Path, newlib: Path, cpp: str):
+    """Generate the target-specific syscall lists."""
+    target_map_c = output_dir / 'target-newlib-syscall.c'
+    old_lines_c = target_map_c.read_text().splitlines()
+    start_i = end_i = None
+    for i, line in enumerate(old_lines_c):
+        if START_MARKER in line:
+            start_i = i
+        if END_MARKER in line:
+            end_i = i
+    assert start_i and end_i, f'{target_map_c}: Unable to find markers'
+    new_lines_c = old_lines_c[0:start_i + 1]
+    new_lines_c_end = old_lines_c[end_i:]
+
+    target_map_h = output_dir / 'target-newlib-syscall.h'
+    old_lines_h = target_map_h.read_text().splitlines()
+    start_i = end_i = None
+    for i, line in enumerate(old_lines_h):
+        if START_MARKER in line:
+            start_i = i
+        if END_MARKER in line:
+            end_i = i
+    assert start_i and end_i, f'{target_map_h}: Unable to find markers'
+    new_lines_h = old_lines_h[0:start_i + 1]
+    new_lines_h_end = old_lines_h[end_i:]
+
+    headers = ('syscall.h',)
+    pattern = r'SYS_[_a-zA-Z0-9]*'
+
+    # Output the target-specific syscalls.
     for target, subdir in sorted(TARGET_DIRS.items()):
-        gentvals(output_dir, output, cpp, 'sys', newlib / subdir,
-                 ('syscall.h',), r'SYS_[_a-zA-Z0-9]*', target=target)
+        syms = extract_syms(cpp, newlib / subdir, headers, pattern)
+        new_lines_c.append(f'CB_TARGET_DEFS_MAP cb_{target}_syscall_map[] = {{')
+        new_lines_c.extend(
+            f'#ifdef CB_{sym}\n'
+            '  { '
+            f'"{sym[4:]}", CB_{sym}, TARGET_NEWLIB_{target.upper()}_{sym}'
+            ' },\n'
+            '#endif' for sym in sorted(syms))
+        new_lines_c.append('  {NULL, -1, -1},')
+        new_lines_c.append('};\n')
+
+        new_lines_h.append(
+            f'extern CB_TARGET_DEFS_MAP cb_{target}_syscall_map[];')
+        new_lines_h.extend(
+            f'#define TARGET_NEWLIB_{target.upper()}_{sym} {val}'
+            for sym, val in sorted(syms.items()))
+        new_lines_h.append('')
 
     # Then output the common syscall targets.
-    gentvals(output_dir, output, cpp, 'sys', newlib / 'libgloss',
-             ('syscall.h',), r'SYS_[_a-zA-Z0-9]*')
+    syms = extract_syms(cpp, newlib / 'libgloss', headers, pattern)
+    new_lines_c.append(f'CB_TARGET_DEFS_MAP cb_init_syscall_map[] = {{')
+    new_lines_c.extend(
+        f'#ifdef CB_{sym}\n'
+        f'  {{ "{sym[4:]}", CB_{sym}, TARGET_NEWLIB_{sym} }},\n'
+        f'#endif' for sym in sorted(syms))
+    new_lines_c.append('  {NULL, -1, -1},')
+    new_lines_c.append('};')
+
+    new_lines_h.append('extern CB_TARGET_DEFS_MAP cb_init_syscall_map[];')
+    new_lines_h.extend(
+        f'#define TARGET_NEWLIB_{sym} {val}'
+        for sym, val in sorted(syms.items()))
+
+    new_lines_c.extend(new_lines_c_end)
+    target_map_c.write_text('\n'.join(new_lines_c) + '\n')
+
+    new_lines_h.extend(new_lines_h_end)
+    target_map_h.write_text('\n'.join(new_lines_h) + '\n')
+
+
+def gen_targets(output_dir: Path, output: TextIO, newlib: Path, cpp: str):
+    """Generate the target-specific lists."""
+    gen_target_syscall(output_dir, newlib, cpp)
 
 
 def gen(output_dir: Path, output: TextIO, newlib: Path, cpp: str):
diff --git a/sim/common/local.mk b/sim/common/local.mk
index 2fd78264ba1f..a83b487f32d8 100644
--- a/sim/common/local.mk
+++ b/sim/common/local.mk
@@ -40,6 +40,7 @@ noinst_LIBRARIES += %D%/libcommon.a
 	%D%/target-newlib-errno.c \
 	%D%/target-newlib-open.c \
 	%D%/target-newlib-signal.c \
+	%D%/target-newlib-syscall.c \
 	%D%/version.c
 
 %D%/version.c: %D%/version.c-stamp ; @true
diff --git a/sim/common/target-newlib-syscall.c b/sim/common/target-newlib-syscall.c
new file mode 100644
index 000000000000..1617ee21b1f5
--- /dev/null
+++ b/sim/common/target-newlib-syscall.c
@@ -0,0 +1,634 @@
+/* Target syscall mappings for newlib/libgloss environment.
+   Copyright 1995-2021 Free Software Foundation, Inc.
+   Contributed by Mike Frysinger.
+
+   This file is part of simulators.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   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 must come before any other includes.  */
+#include "defs.h"
+
+#include "sim/callback.h"
+
+#include "target-newlib-syscall.h"
+
+/* This file is kept up-to-date via the gennltvals.py script.  Do not edit
+   anything between the START & END comment blocks below.  */
+
+  /* gennltvals: START */
+CB_TARGET_DEFS_MAP cb_cr16_syscall_map[] = {
+#ifdef CB_SYS_ARG
+  { "ARG", CB_SYS_ARG, TARGET_NEWLIB_CR16_SYS_ARG },
+#endif
+#ifdef CB_SYS_chdir
+  { "chdir", CB_SYS_chdir, TARGET_NEWLIB_CR16_SYS_chdir },
+#endif
+#ifdef CB_SYS_chmod
+  { "chmod", CB_SYS_chmod, TARGET_NEWLIB_CR16_SYS_chmod },
+#endif
+#ifdef CB_SYS_chown
+  { "chown", CB_SYS_chown, TARGET_NEWLIB_CR16_SYS_chown },
+#endif
+#ifdef CB_SYS_close
+  { "close", CB_SYS_close, TARGET_NEWLIB_CR16_SYS_close },
+#endif
+#ifdef CB_SYS_create
+  { "create", CB_SYS_create, TARGET_NEWLIB_CR16_SYS_create },
+#endif
+#ifdef CB_SYS_execv
+  { "execv", CB_SYS_execv, TARGET_NEWLIB_CR16_SYS_execv },
+#endif
+#ifdef CB_SYS_execve
+  { "execve", CB_SYS_execve, TARGET_NEWLIB_CR16_SYS_execve },
+#endif
+#ifdef CB_SYS_exit
+  { "exit", CB_SYS_exit, TARGET_NEWLIB_CR16_SYS_exit },
+#endif
+#ifdef CB_SYS_fork
+  { "fork", CB_SYS_fork, TARGET_NEWLIB_CR16_SYS_fork },
+#endif
+#ifdef CB_SYS_fstat
+  { "fstat", CB_SYS_fstat, TARGET_NEWLIB_CR16_SYS_fstat },
+#endif
+#ifdef CB_SYS_getpid
+  { "getpid", CB_SYS_getpid, TARGET_NEWLIB_CR16_SYS_getpid },
+#endif
+#ifdef CB_SYS_isatty
+  { "isatty", CB_SYS_isatty, TARGET_NEWLIB_CR16_SYS_isatty },
+#endif
+#ifdef CB_SYS_kill
+  { "kill", CB_SYS_kill, TARGET_NEWLIB_CR16_SYS_kill },
+#endif
+#ifdef CB_SYS_link
+  { "link", CB_SYS_link, TARGET_NEWLIB_CR16_SYS_link },
+#endif
+#ifdef CB_SYS_lseek
+  { "lseek", CB_SYS_lseek, TARGET_NEWLIB_CR16_SYS_lseek },
+#endif
+#ifdef CB_SYS_mknod
+  { "mknod", CB_SYS_mknod, TARGET_NEWLIB_CR16_SYS_mknod },
+#endif
+#ifdef CB_SYS_open
+  { "open", CB_SYS_open, TARGET_NEWLIB_CR16_SYS_open },
+#endif
+#ifdef CB_SYS_pipe
+  { "pipe", CB_SYS_pipe, TARGET_NEWLIB_CR16_SYS_pipe },
+#endif
+#ifdef CB_SYS_read
+  { "read", CB_SYS_read, TARGET_NEWLIB_CR16_SYS_read },
+#endif
+#ifdef CB_SYS_rename
+  { "rename", CB_SYS_rename, TARGET_NEWLIB_CR16_SYS_rename },
+#endif
+#ifdef CB_SYS_stat
+  { "stat", CB_SYS_stat, TARGET_NEWLIB_CR16_SYS_stat },
+#endif
+#ifdef CB_SYS_time
+  { "time", CB_SYS_time, TARGET_NEWLIB_CR16_SYS_time },
+#endif
+#ifdef CB_SYS_unlink
+  { "unlink", CB_SYS_unlink, TARGET_NEWLIB_CR16_SYS_unlink },
+#endif
+#ifdef CB_SYS_utime
+  { "utime", CB_SYS_utime, TARGET_NEWLIB_CR16_SYS_utime },
+#endif
+#ifdef CB_SYS_wait
+  { "wait", CB_SYS_wait, TARGET_NEWLIB_CR16_SYS_wait },
+#endif
+#ifdef CB_SYS_wait4
+  { "wait4", CB_SYS_wait4, TARGET_NEWLIB_CR16_SYS_wait4 },
+#endif
+#ifdef CB_SYS_write
+  { "write", CB_SYS_write, TARGET_NEWLIB_CR16_SYS_write },
+#endif
+  {NULL, -1, -1},
+};
+
+CB_TARGET_DEFS_MAP cb_d10v_syscall_map[] = {
+#ifdef CB_SYS_ARG
+  { "ARG", CB_SYS_ARG, TARGET_NEWLIB_D10V_SYS_ARG },
+#endif
+#ifdef CB_SYS_chdir
+  { "chdir", CB_SYS_chdir, TARGET_NEWLIB_D10V_SYS_chdir },
+#endif
+#ifdef CB_SYS_chmod
+  { "chmod", CB_SYS_chmod, TARGET_NEWLIB_D10V_SYS_chmod },
+#endif
+#ifdef CB_SYS_chown
+  { "chown", CB_SYS_chown, TARGET_NEWLIB_D10V_SYS_chown },
+#endif
+#ifdef CB_SYS_close
+  { "close", CB_SYS_close, TARGET_NEWLIB_D10V_SYS_close },
+#endif
+#ifdef CB_SYS_creat
+  { "creat", CB_SYS_creat, TARGET_NEWLIB_D10V_SYS_creat },
+#endif
+#ifdef CB_SYS_execv
+  { "execv", CB_SYS_execv, TARGET_NEWLIB_D10V_SYS_execv },
+#endif
+#ifdef CB_SYS_execve
+  { "execve", CB_SYS_execve, TARGET_NEWLIB_D10V_SYS_execve },
+#endif
+#ifdef CB_SYS_exit
+  { "exit", CB_SYS_exit, TARGET_NEWLIB_D10V_SYS_exit },
+#endif
+#ifdef CB_SYS_fork
+  { "fork", CB_SYS_fork, TARGET_NEWLIB_D10V_SYS_fork },
+#endif
+#ifdef CB_SYS_fstat
+  { "fstat", CB_SYS_fstat, TARGET_NEWLIB_D10V_SYS_fstat },
+#endif
+#ifdef CB_SYS_getpid
+  { "getpid", CB_SYS_getpid, TARGET_NEWLIB_D10V_SYS_getpid },
+#endif
+#ifdef CB_SYS_isatty
+  { "isatty", CB_SYS_isatty, TARGET_NEWLIB_D10V_SYS_isatty },
+#endif
+#ifdef CB_SYS_kill
+  { "kill", CB_SYS_kill, TARGET_NEWLIB_D10V_SYS_kill },
+#endif
+#ifdef CB_SYS_link
+  { "link", CB_SYS_link, TARGET_NEWLIB_D10V_SYS_link },
+#endif
+#ifdef CB_SYS_lseek
+  { "lseek", CB_SYS_lseek, TARGET_NEWLIB_D10V_SYS_lseek },
+#endif
+#ifdef CB_SYS_mknod
+  { "mknod", CB_SYS_mknod, TARGET_NEWLIB_D10V_SYS_mknod },
+#endif
+#ifdef CB_SYS_open
+  { "open", CB_SYS_open, TARGET_NEWLIB_D10V_SYS_open },
+#endif
+#ifdef CB_SYS_pipe
+  { "pipe", CB_SYS_pipe, TARGET_NEWLIB_D10V_SYS_pipe },
+#endif
+#ifdef CB_SYS_read
+  { "read", CB_SYS_read, TARGET_NEWLIB_D10V_SYS_read },
+#endif
+#ifdef CB_SYS_stat
+  { "stat", CB_SYS_stat, TARGET_NEWLIB_D10V_SYS_stat },
+#endif
+#ifdef CB_SYS_time
+  { "time", CB_SYS_time, TARGET_NEWLIB_D10V_SYS_time },
+#endif
+#ifdef CB_SYS_unlink
+  { "unlink", CB_SYS_unlink, TARGET_NEWLIB_D10V_SYS_unlink },
+#endif
+#ifdef CB_SYS_utime
+  { "utime", CB_SYS_utime, TARGET_NEWLIB_D10V_SYS_utime },
+#endif
+#ifdef CB_SYS_wait
+  { "wait", CB_SYS_wait, TARGET_NEWLIB_D10V_SYS_wait },
+#endif
+#ifdef CB_SYS_wait4
+  { "wait4", CB_SYS_wait4, TARGET_NEWLIB_D10V_SYS_wait4 },
+#endif
+#ifdef CB_SYS_write
+  { "write", CB_SYS_write, TARGET_NEWLIB_D10V_SYS_write },
+#endif
+  {NULL, -1, -1},
+};
+
+CB_TARGET_DEFS_MAP cb_mcore_syscall_map[] = {
+#ifdef CB_SYS_access
+  { "access", CB_SYS_access, TARGET_NEWLIB_MCORE_SYS_access },
+#endif
+#ifdef CB_SYS_close
+  { "close", CB_SYS_close, TARGET_NEWLIB_MCORE_SYS_close },
+#endif
+#ifdef CB_SYS_creat
+  { "creat", CB_SYS_creat, TARGET_NEWLIB_MCORE_SYS_creat },
+#endif
+#ifdef CB_SYS_link
+  { "link", CB_SYS_link, TARGET_NEWLIB_MCORE_SYS_link },
+#endif
+#ifdef CB_SYS_lseek
+  { "lseek", CB_SYS_lseek, TARGET_NEWLIB_MCORE_SYS_lseek },
+#endif
+#ifdef CB_SYS_open
+  { "open", CB_SYS_open, TARGET_NEWLIB_MCORE_SYS_open },
+#endif
+#ifdef CB_SYS_read
+  { "read", CB_SYS_read, TARGET_NEWLIB_MCORE_SYS_read },
+#endif
+#ifdef CB_SYS_time
+  { "time", CB_SYS_time, TARGET_NEWLIB_MCORE_SYS_time },
+#endif
+#ifdef CB_SYS_times
+  { "times", CB_SYS_times, TARGET_NEWLIB_MCORE_SYS_times },
+#endif
+#ifdef CB_SYS_unlink
+  { "unlink", CB_SYS_unlink, TARGET_NEWLIB_MCORE_SYS_unlink },
+#endif
+#ifdef CB_SYS_write
+  { "write", CB_SYS_write, TARGET_NEWLIB_MCORE_SYS_write },
+#endif
+  {NULL, -1, -1},
+};
+
+CB_TARGET_DEFS_MAP cb_riscv_syscall_map[] = {
+#ifdef CB_SYS_access
+  { "access", CB_SYS_access, TARGET_NEWLIB_RISCV_SYS_access },
+#endif
+#ifdef CB_SYS_brk
+  { "brk", CB_SYS_brk, TARGET_NEWLIB_RISCV_SYS_brk },
+#endif
+#ifdef CB_SYS_chdir
+  { "chdir", CB_SYS_chdir, TARGET_NEWLIB_RISCV_SYS_chdir },
+#endif
+#ifdef CB_SYS_clock_gettime64
+  { "clock_gettime64", CB_SYS_clock_gettime64, TARGET_NEWLIB_RISCV_SYS_clock_gettime64 },
+#endif
+#ifdef CB_SYS_close
+  { "close", CB_SYS_close, TARGET_NEWLIB_RISCV_SYS_close },
+#endif
+#ifdef CB_SYS_dup
+  { "dup", CB_SYS_dup, TARGET_NEWLIB_RISCV_SYS_dup },
+#endif
+#ifdef CB_SYS_exit
+  { "exit", CB_SYS_exit, TARGET_NEWLIB_RISCV_SYS_exit },
+#endif
+#ifdef CB_SYS_exit_group
+  { "exit_group", CB_SYS_exit_group, TARGET_NEWLIB_RISCV_SYS_exit_group },
+#endif
+#ifdef CB_SYS_faccessat
+  { "faccessat", CB_SYS_faccessat, TARGET_NEWLIB_RISCV_SYS_faccessat },
+#endif
+#ifdef CB_SYS_fcntl
+  { "fcntl", CB_SYS_fcntl, TARGET_NEWLIB_RISCV_SYS_fcntl },
+#endif
+#ifdef CB_SYS_fstat
+  { "fstat", CB_SYS_fstat, TARGET_NEWLIB_RISCV_SYS_fstat },
+#endif
+#ifdef CB_SYS_fstatat
+  { "fstatat", CB_SYS_fstatat, TARGET_NEWLIB_RISCV_SYS_fstatat },
+#endif
+#ifdef CB_SYS_getcwd
+  { "getcwd", CB_SYS_getcwd, TARGET_NEWLIB_RISCV_SYS_getcwd },
+#endif
+#ifdef CB_SYS_getdents
+  { "getdents", CB_SYS_getdents, TARGET_NEWLIB_RISCV_SYS_getdents },
+#endif
+#ifdef CB_SYS_getegid
+  { "getegid", CB_SYS_getegid, TARGET_NEWLIB_RISCV_SYS_getegid },
+#endif
+#ifdef CB_SYS_geteuid
+  { "geteuid", CB_SYS_geteuid, TARGET_NEWLIB_RISCV_SYS_geteuid },
+#endif
+#ifdef CB_SYS_getgid
+  { "getgid", CB_SYS_getgid, TARGET_NEWLIB_RISCV_SYS_getgid },
+#endif
+#ifdef CB_SYS_getmainvars
+  { "getmainvars", CB_SYS_getmainvars, TARGET_NEWLIB_RISCV_SYS_getmainvars },
+#endif
+#ifdef CB_SYS_getpid
+  { "getpid", CB_SYS_getpid, TARGET_NEWLIB_RISCV_SYS_getpid },
+#endif
+#ifdef CB_SYS_gettimeofday
+  { "gettimeofday", CB_SYS_gettimeofday, TARGET_NEWLIB_RISCV_SYS_gettimeofday },
+#endif
+#ifdef CB_SYS_getuid
+  { "getuid", CB_SYS_getuid, TARGET_NEWLIB_RISCV_SYS_getuid },
+#endif
+#ifdef CB_SYS_kill
+  { "kill", CB_SYS_kill, TARGET_NEWLIB_RISCV_SYS_kill },
+#endif
+#ifdef CB_SYS_link
+  { "link", CB_SYS_link, TARGET_NEWLIB_RISCV_SYS_link },
+#endif
+#ifdef CB_SYS_lseek
+  { "lseek", CB_SYS_lseek, TARGET_NEWLIB_RISCV_SYS_lseek },
+#endif
+#ifdef CB_SYS_lstat
+  { "lstat", CB_SYS_lstat, TARGET_NEWLIB_RISCV_SYS_lstat },
+#endif
+#ifdef CB_SYS_mkdir
+  { "mkdir", CB_SYS_mkdir, TARGET_NEWLIB_RISCV_SYS_mkdir },
+#endif
+#ifdef CB_SYS_mmap
+  { "mmap", CB_SYS_mmap, TARGET_NEWLIB_RISCV_SYS_mmap },
+#endif
+#ifdef CB_SYS_mremap
+  { "mremap", CB_SYS_mremap, TARGET_NEWLIB_RISCV_SYS_mremap },
+#endif
+#ifdef CB_SYS_munmap
+  { "munmap", CB_SYS_munmap, TARGET_NEWLIB_RISCV_SYS_munmap },
+#endif
+#ifdef CB_SYS_open
+  { "open", CB_SYS_open, TARGET_NEWLIB_RISCV_SYS_open },
+#endif
+#ifdef CB_SYS_openat
+  { "openat", CB_SYS_openat, TARGET_NEWLIB_RISCV_SYS_openat },
+#endif
+#ifdef CB_SYS_pread
+  { "pread", CB_SYS_pread, TARGET_NEWLIB_RISCV_SYS_pread },
+#endif
+#ifdef CB_SYS_pwrite
+  { "pwrite", CB_SYS_pwrite, TARGET_NEWLIB_RISCV_SYS_pwrite },
+#endif
+#ifdef CB_SYS_read
+  { "read", CB_SYS_read, TARGET_NEWLIB_RISCV_SYS_read },
+#endif
+#ifdef CB_SYS_rt_sigaction
+  { "rt_sigaction", CB_SYS_rt_sigaction, TARGET_NEWLIB_RISCV_SYS_rt_sigaction },
+#endif
+#ifdef CB_SYS_stat
+  { "stat", CB_SYS_stat, TARGET_NEWLIB_RISCV_SYS_stat },
+#endif
+#ifdef CB_SYS_time
+  { "time", CB_SYS_time, TARGET_NEWLIB_RISCV_SYS_time },
+#endif
+#ifdef CB_SYS_times
+  { "times", CB_SYS_times, TARGET_NEWLIB_RISCV_SYS_times },
+#endif
+#ifdef CB_SYS_uname
+  { "uname", CB_SYS_uname, TARGET_NEWLIB_RISCV_SYS_uname },
+#endif
+#ifdef CB_SYS_unlink
+  { "unlink", CB_SYS_unlink, TARGET_NEWLIB_RISCV_SYS_unlink },
+#endif
+#ifdef CB_SYS_write
+  { "write", CB_SYS_write, TARGET_NEWLIB_RISCV_SYS_write },
+#endif
+#ifdef CB_SYS_writev
+  { "writev", CB_SYS_writev, TARGET_NEWLIB_RISCV_SYS_writev },
+#endif
+  {NULL, -1, -1},
+};
+
+CB_TARGET_DEFS_MAP cb_sh_syscall_map[] = {
+#ifdef CB_SYS_ARG
+  { "ARG", CB_SYS_ARG, TARGET_NEWLIB_SH_SYS_ARG },
+#endif
+#ifdef CB_SYS_argc
+  { "argc", CB_SYS_argc, TARGET_NEWLIB_SH_SYS_argc },
+#endif
+#ifdef CB_SYS_argn
+  { "argn", CB_SYS_argn, TARGET_NEWLIB_SH_SYS_argn },
+#endif
+#ifdef CB_SYS_argnlen
+  { "argnlen", CB_SYS_argnlen, TARGET_NEWLIB_SH_SYS_argnlen },
+#endif
+#ifdef CB_SYS_chdir
+  { "chdir", CB_SYS_chdir, TARGET_NEWLIB_SH_SYS_chdir },
+#endif
+#ifdef CB_SYS_chmod
+  { "chmod", CB_SYS_chmod, TARGET_NEWLIB_SH_SYS_chmod },
+#endif
+#ifdef CB_SYS_chown
+  { "chown", CB_SYS_chown, TARGET_NEWLIB_SH_SYS_chown },
+#endif
+#ifdef CB_SYS_close
+  { "close", CB_SYS_close, TARGET_NEWLIB_SH_SYS_close },
+#endif
+#ifdef CB_SYS_creat
+  { "creat", CB_SYS_creat, TARGET_NEWLIB_SH_SYS_creat },
+#endif
+#ifdef CB_SYS_execv
+  { "execv", CB_SYS_execv, TARGET_NEWLIB_SH_SYS_execv },
+#endif
+#ifdef CB_SYS_execve
+  { "execve", CB_SYS_execve, TARGET_NEWLIB_SH_SYS_execve },
+#endif
+#ifdef CB_SYS_exit
+  { "exit", CB_SYS_exit, TARGET_NEWLIB_SH_SYS_exit },
+#endif
+#ifdef CB_SYS_fork
+  { "fork", CB_SYS_fork, TARGET_NEWLIB_SH_SYS_fork },
+#endif
+#ifdef CB_SYS_fstat
+  { "fstat", CB_SYS_fstat, TARGET_NEWLIB_SH_SYS_fstat },
+#endif
+#ifdef CB_SYS_ftruncate
+  { "ftruncate", CB_SYS_ftruncate, TARGET_NEWLIB_SH_SYS_ftruncate },
+#endif
+#ifdef CB_SYS_getpid
+  { "getpid", CB_SYS_getpid, TARGET_NEWLIB_SH_SYS_getpid },
+#endif
+#ifdef CB_SYS_isatty
+  { "isatty", CB_SYS_isatty, TARGET_NEWLIB_SH_SYS_isatty },
+#endif
+#ifdef CB_SYS_link
+  { "link", CB_SYS_link, TARGET_NEWLIB_SH_SYS_link },
+#endif
+#ifdef CB_SYS_lseek
+  { "lseek", CB_SYS_lseek, TARGET_NEWLIB_SH_SYS_lseek },
+#endif
+#ifdef CB_SYS_mknod
+  { "mknod", CB_SYS_mknod, TARGET_NEWLIB_SH_SYS_mknod },
+#endif
+#ifdef CB_SYS_open
+  { "open", CB_SYS_open, TARGET_NEWLIB_SH_SYS_open },
+#endif
+#ifdef CB_SYS_pipe
+  { "pipe", CB_SYS_pipe, TARGET_NEWLIB_SH_SYS_pipe },
+#endif
+#ifdef CB_SYS_read
+  { "read", CB_SYS_read, TARGET_NEWLIB_SH_SYS_read },
+#endif
+#ifdef CB_SYS_stat
+  { "stat", CB_SYS_stat, TARGET_NEWLIB_SH_SYS_stat },
+#endif
+#ifdef CB_SYS_time
+  { "time", CB_SYS_time, TARGET_NEWLIB_SH_SYS_time },
+#endif
+#ifdef CB_SYS_truncate
+  { "truncate", CB_SYS_truncate, TARGET_NEWLIB_SH_SYS_truncate },
+#endif
+#ifdef CB_SYS_unlink
+  { "unlink", CB_SYS_unlink, TARGET_NEWLIB_SH_SYS_unlink },
+#endif
+#ifdef CB_SYS_utime
+  { "utime", CB_SYS_utime, TARGET_NEWLIB_SH_SYS_utime },
+#endif
+#ifdef CB_SYS_wait
+  { "wait", CB_SYS_wait, TARGET_NEWLIB_SH_SYS_wait },
+#endif
+#ifdef CB_SYS_wait4
+  { "wait4", CB_SYS_wait4, TARGET_NEWLIB_SH_SYS_wait4 },
+#endif
+#ifdef CB_SYS_write
+  { "write", CB_SYS_write, TARGET_NEWLIB_SH_SYS_write },
+#endif
+  {NULL, -1, -1},
+};
+
+CB_TARGET_DEFS_MAP cb_v850_syscall_map[] = {
+#ifdef CB_SYS_ARG
+  { "ARG", CB_SYS_ARG, TARGET_NEWLIB_V850_SYS_ARG },
+#endif
+#ifdef CB_SYS_chdir
+  { "chdir", CB_SYS_chdir, TARGET_NEWLIB_V850_SYS_chdir },
+#endif
+#ifdef CB_SYS_chmod
+  { "chmod", CB_SYS_chmod, TARGET_NEWLIB_V850_SYS_chmod },
+#endif
+#ifdef CB_SYS_chown
+  { "chown", CB_SYS_chown, TARGET_NEWLIB_V850_SYS_chown },
+#endif
+#ifdef CB_SYS_close
+  { "close", CB_SYS_close, TARGET_NEWLIB_V850_SYS_close },
+#endif
+#ifdef CB_SYS_creat
+  { "creat", CB_SYS_creat, TARGET_NEWLIB_V850_SYS_creat },
+#endif
+#ifdef CB_SYS_execv
+  { "execv", CB_SYS_execv, TARGET_NEWLIB_V850_SYS_execv },
+#endif
+#ifdef CB_SYS_execve
+  { "execve", CB_SYS_execve, TARGET_NEWLIB_V850_SYS_execve },
+#endif
+#ifdef CB_SYS_exit
+  { "exit", CB_SYS_exit, TARGET_NEWLIB_V850_SYS_exit },
+#endif
+#ifdef CB_SYS_fork
+  { "fork", CB_SYS_fork, TARGET_NEWLIB_V850_SYS_fork },
+#endif
+#ifdef CB_SYS_fstat
+  { "fstat", CB_SYS_fstat, TARGET_NEWLIB_V850_SYS_fstat },
+#endif
+#ifdef CB_SYS_getpid
+  { "getpid", CB_SYS_getpid, TARGET_NEWLIB_V850_SYS_getpid },
+#endif
+#ifdef CB_SYS_gettimeofday
+  { "gettimeofday", CB_SYS_gettimeofday, TARGET_NEWLIB_V850_SYS_gettimeofday },
+#endif
+#ifdef CB_SYS_isatty
+  { "isatty", CB_SYS_isatty, TARGET_NEWLIB_V850_SYS_isatty },
+#endif
+#ifdef CB_SYS_link
+  { "link", CB_SYS_link, TARGET_NEWLIB_V850_SYS_link },
+#endif
+#ifdef CB_SYS_lseek
+  { "lseek", CB_SYS_lseek, TARGET_NEWLIB_V850_SYS_lseek },
+#endif
+#ifdef CB_SYS_mknod
+  { "mknod", CB_SYS_mknod, TARGET_NEWLIB_V850_SYS_mknod },
+#endif
+#ifdef CB_SYS_open
+  { "open", CB_SYS_open, TARGET_NEWLIB_V850_SYS_open },
+#endif
+#ifdef CB_SYS_pipe
+  { "pipe", CB_SYS_pipe, TARGET_NEWLIB_V850_SYS_pipe },
+#endif
+#ifdef CB_SYS_read
+  { "read", CB_SYS_read, TARGET_NEWLIB_V850_SYS_read },
+#endif
+#ifdef CB_SYS_rename
+  { "rename", CB_SYS_rename, TARGET_NEWLIB_V850_SYS_rename },
+#endif
+#ifdef CB_SYS_stat
+  { "stat", CB_SYS_stat, TARGET_NEWLIB_V850_SYS_stat },
+#endif
+#ifdef CB_SYS_time
+  { "time", CB_SYS_time, TARGET_NEWLIB_V850_SYS_time },
+#endif
+#ifdef CB_SYS_times
+  { "times", CB_SYS_times, TARGET_NEWLIB_V850_SYS_times },
+#endif
+#ifdef CB_SYS_unlink
+  { "unlink", CB_SYS_unlink, TARGET_NEWLIB_V850_SYS_unlink },
+#endif
+#ifdef CB_SYS_utime
+  { "utime", CB_SYS_utime, TARGET_NEWLIB_V850_SYS_utime },
+#endif
+#ifdef CB_SYS_wait
+  { "wait", CB_SYS_wait, TARGET_NEWLIB_V850_SYS_wait },
+#endif
+#ifdef CB_SYS_wait4
+  { "wait4", CB_SYS_wait4, TARGET_NEWLIB_V850_SYS_wait4 },
+#endif
+#ifdef CB_SYS_write
+  { "write", CB_SYS_write, TARGET_NEWLIB_V850_SYS_write },
+#endif
+  {NULL, -1, -1},
+};
+
+CB_TARGET_DEFS_MAP cb_init_syscall_map[] = {
+#ifdef CB_SYS_argc
+  { "argc", CB_SYS_argc, TARGET_NEWLIB_SYS_argc },
+#endif
+#ifdef CB_SYS_argn
+  { "argn", CB_SYS_argn, TARGET_NEWLIB_SYS_argn },
+#endif
+#ifdef CB_SYS_argnlen
+  { "argnlen", CB_SYS_argnlen, TARGET_NEWLIB_SYS_argnlen },
+#endif
+#ifdef CB_SYS_argv
+  { "argv", CB_SYS_argv, TARGET_NEWLIB_SYS_argv },
+#endif
+#ifdef CB_SYS_argvlen
+  { "argvlen", CB_SYS_argvlen, TARGET_NEWLIB_SYS_argvlen },
+#endif
+#ifdef CB_SYS_chdir
+  { "chdir", CB_SYS_chdir, TARGET_NEWLIB_SYS_chdir },
+#endif
+#ifdef CB_SYS_chmod
+  { "chmod", CB_SYS_chmod, TARGET_NEWLIB_SYS_chmod },
+#endif
+#ifdef CB_SYS_close
+  { "close", CB_SYS_close, TARGET_NEWLIB_SYS_close },
+#endif
+#ifdef CB_SYS_exit
+  { "exit", CB_SYS_exit, TARGET_NEWLIB_SYS_exit },
+#endif
+#ifdef CB_SYS_fstat
+  { "fstat", CB_SYS_fstat, TARGET_NEWLIB_SYS_fstat },
+#endif
+#ifdef CB_SYS_getpid
+  { "getpid", CB_SYS_getpid, TARGET_NEWLIB_SYS_getpid },
+#endif
+#ifdef CB_SYS_gettimeofday
+  { "gettimeofday", CB_SYS_gettimeofday, TARGET_NEWLIB_SYS_gettimeofday },
+#endif
+#ifdef CB_SYS_kill
+  { "kill", CB_SYS_kill, TARGET_NEWLIB_SYS_kill },
+#endif
+#ifdef CB_SYS_link
+  { "link", CB_SYS_link, TARGET_NEWLIB_SYS_link },
+#endif
+#ifdef CB_SYS_lseek
+  { "lseek", CB_SYS_lseek, TARGET_NEWLIB_SYS_lseek },
+#endif
+#ifdef CB_SYS_open
+  { "open", CB_SYS_open, TARGET_NEWLIB_SYS_open },
+#endif
+#ifdef CB_SYS_read
+  { "read", CB_SYS_read, TARGET_NEWLIB_SYS_read },
+#endif
+#ifdef CB_SYS_reconfig
+  { "reconfig", CB_SYS_reconfig, TARGET_NEWLIB_SYS_reconfig },
+#endif
+#ifdef CB_SYS_stat
+  { "stat", CB_SYS_stat, TARGET_NEWLIB_SYS_stat },
+#endif
+#ifdef CB_SYS_time
+  { "time", CB_SYS_time, TARGET_NEWLIB_SYS_time },
+#endif
+#ifdef CB_SYS_times
+  { "times", CB_SYS_times, TARGET_NEWLIB_SYS_times },
+#endif
+#ifdef CB_SYS_unlink
+  { "unlink", CB_SYS_unlink, TARGET_NEWLIB_SYS_unlink },
+#endif
+#ifdef CB_SYS_utime
+  { "utime", CB_SYS_utime, TARGET_NEWLIB_SYS_utime },
+#endif
+#ifdef CB_SYS_write
+  { "write", CB_SYS_write, TARGET_NEWLIB_SYS_write },
+#endif
+  {NULL, -1, -1},
+};
+  /* gennltvals: END */
diff --git a/sim/common/target-newlib-syscall.h b/sim/common/target-newlib-syscall.h
new file mode 100644
index 000000000000..fed9da5985b8
--- /dev/null
+++ b/sim/common/target-newlib-syscall.h
@@ -0,0 +1,237 @@
+/* Target syscall mappings for newlib/libgloss environment.
+   Copyright 1995-2021 Free Software Foundation, Inc.
+   Contributed by Mike Frysinger.
+
+   This file is part of simulators.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef TARGET_NEWLIB_SYSCALL_H
+#define TARGET_NEWLIB_SYSCALL_H
+
+/* For CB_TARGET_DEFS_MAP.  */
+#include "sim/callback.h"
+
+/* This file is kept up-to-date via the gennltvals.py script.  Do not edit
+   anything between the START & END comment blocks below.  */
+
+  /* gennltvals: START */
+extern CB_TARGET_DEFS_MAP cb_cr16_syscall_map[];
+#define TARGET_NEWLIB_CR16_SYS_ARG 24
+#define TARGET_NEWLIB_CR16_SYS_chdir 12
+#define TARGET_NEWLIB_CR16_SYS_chmod 15
+#define TARGET_NEWLIB_CR16_SYS_chown 16
+#define TARGET_NEWLIB_CR16_SYS_close 0x402
+#define TARGET_NEWLIB_CR16_SYS_create 8
+#define TARGET_NEWLIB_CR16_SYS_execv 11
+#define TARGET_NEWLIB_CR16_SYS_execve 59
+#define TARGET_NEWLIB_CR16_SYS_exit 0x410
+#define TARGET_NEWLIB_CR16_SYS_fork 2
+#define TARGET_NEWLIB_CR16_SYS_fstat 22
+#define TARGET_NEWLIB_CR16_SYS_getpid 20
+#define TARGET_NEWLIB_CR16_SYS_isatty 21
+#define TARGET_NEWLIB_CR16_SYS_kill 60
+#define TARGET_NEWLIB_CR16_SYS_link 9
+#define TARGET_NEWLIB_CR16_SYS_lseek 0x405
+#define TARGET_NEWLIB_CR16_SYS_mknod 14
+#define TARGET_NEWLIB_CR16_SYS_open 0x401
+#define TARGET_NEWLIB_CR16_SYS_pipe 42
+#define TARGET_NEWLIB_CR16_SYS_read 0x403
+#define TARGET_NEWLIB_CR16_SYS_rename 0x406
+#define TARGET_NEWLIB_CR16_SYS_stat 38
+#define TARGET_NEWLIB_CR16_SYS_time 0x300
+#define TARGET_NEWLIB_CR16_SYS_unlink 0x407
+#define TARGET_NEWLIB_CR16_SYS_utime 201
+#define TARGET_NEWLIB_CR16_SYS_wait 202
+#define TARGET_NEWLIB_CR16_SYS_wait4 7
+#define TARGET_NEWLIB_CR16_SYS_write 0x404
+
+extern CB_TARGET_DEFS_MAP cb_d10v_syscall_map[];
+#define TARGET_NEWLIB_D10V_SYS_ARG 24
+#define TARGET_NEWLIB_D10V_SYS_chdir 12
+#define TARGET_NEWLIB_D10V_SYS_chmod 15
+#define TARGET_NEWLIB_D10V_SYS_chown 16
+#define TARGET_NEWLIB_D10V_SYS_close 6
+#define TARGET_NEWLIB_D10V_SYS_creat 8
+#define TARGET_NEWLIB_D10V_SYS_execv 11
+#define TARGET_NEWLIB_D10V_SYS_execve 59
+#define TARGET_NEWLIB_D10V_SYS_exit 1
+#define TARGET_NEWLIB_D10V_SYS_fork 2
+#define TARGET_NEWLIB_D10V_SYS_fstat 22
+#define TARGET_NEWLIB_D10V_SYS_getpid 20
+#define TARGET_NEWLIB_D10V_SYS_isatty 21
+#define TARGET_NEWLIB_D10V_SYS_kill 60
+#define TARGET_NEWLIB_D10V_SYS_link 9
+#define TARGET_NEWLIB_D10V_SYS_lseek 19
+#define TARGET_NEWLIB_D10V_SYS_mknod 14
+#define TARGET_NEWLIB_D10V_SYS_open 5
+#define TARGET_NEWLIB_D10V_SYS_pipe 42
+#define TARGET_NEWLIB_D10V_SYS_read 3
+#define TARGET_NEWLIB_D10V_SYS_stat 38
+#define TARGET_NEWLIB_D10V_SYS_time 23
+#define TARGET_NEWLIB_D10V_SYS_unlink 10
+#define TARGET_NEWLIB_D10V_SYS_utime 201
+#define TARGET_NEWLIB_D10V_SYS_wait 202
+#define TARGET_NEWLIB_D10V_SYS_wait4 7
+#define TARGET_NEWLIB_D10V_SYS_write 4
+
+extern CB_TARGET_DEFS_MAP cb_mcore_syscall_map[];
+#define TARGET_NEWLIB_MCORE_SYS_access 33
+#define TARGET_NEWLIB_MCORE_SYS_close 6
+#define TARGET_NEWLIB_MCORE_SYS_creat 8
+#define TARGET_NEWLIB_MCORE_SYS_link 9
+#define TARGET_NEWLIB_MCORE_SYS_lseek 19
+#define TARGET_NEWLIB_MCORE_SYS_open 5
+#define TARGET_NEWLIB_MCORE_SYS_read 3
+#define TARGET_NEWLIB_MCORE_SYS_time 13
+#define TARGET_NEWLIB_MCORE_SYS_times 43
+#define TARGET_NEWLIB_MCORE_SYS_unlink 10
+#define TARGET_NEWLIB_MCORE_SYS_write 4
+
+extern CB_TARGET_DEFS_MAP cb_riscv_syscall_map[];
+#define TARGET_NEWLIB_RISCV_SYS_access 1033
+#define TARGET_NEWLIB_RISCV_SYS_brk 214
+#define TARGET_NEWLIB_RISCV_SYS_chdir 49
+#define TARGET_NEWLIB_RISCV_SYS_clock_gettime64 403
+#define TARGET_NEWLIB_RISCV_SYS_close 57
+#define TARGET_NEWLIB_RISCV_SYS_dup 23
+#define TARGET_NEWLIB_RISCV_SYS_exit 93
+#define TARGET_NEWLIB_RISCV_SYS_exit_group 94
+#define TARGET_NEWLIB_RISCV_SYS_faccessat 48
+#define TARGET_NEWLIB_RISCV_SYS_fcntl 25
+#define TARGET_NEWLIB_RISCV_SYS_fstat 80
+#define TARGET_NEWLIB_RISCV_SYS_fstatat 79
+#define TARGET_NEWLIB_RISCV_SYS_getcwd 17
+#define TARGET_NEWLIB_RISCV_SYS_getdents 61
+#define TARGET_NEWLIB_RISCV_SYS_getegid 177
+#define TARGET_NEWLIB_RISCV_SYS_geteuid 175
+#define TARGET_NEWLIB_RISCV_SYS_getgid 176
+#define TARGET_NEWLIB_RISCV_SYS_getmainvars 2011
+#define TARGET_NEWLIB_RISCV_SYS_getpid 172
+#define TARGET_NEWLIB_RISCV_SYS_gettimeofday 169
+#define TARGET_NEWLIB_RISCV_SYS_getuid 174
+#define TARGET_NEWLIB_RISCV_SYS_kill 129
+#define TARGET_NEWLIB_RISCV_SYS_link 1025
+#define TARGET_NEWLIB_RISCV_SYS_lseek 62
+#define TARGET_NEWLIB_RISCV_SYS_lstat 1039
+#define TARGET_NEWLIB_RISCV_SYS_mkdir 1030
+#define TARGET_NEWLIB_RISCV_SYS_mmap 222
+#define TARGET_NEWLIB_RISCV_SYS_mremap 216
+#define TARGET_NEWLIB_RISCV_SYS_munmap 215
+#define TARGET_NEWLIB_RISCV_SYS_open 1024
+#define TARGET_NEWLIB_RISCV_SYS_openat 56
+#define TARGET_NEWLIB_RISCV_SYS_pread 67
+#define TARGET_NEWLIB_RISCV_SYS_pwrite 68
+#define TARGET_NEWLIB_RISCV_SYS_read 63
+#define TARGET_NEWLIB_RISCV_SYS_rt_sigaction 134
+#define TARGET_NEWLIB_RISCV_SYS_stat 1038
+#define TARGET_NEWLIB_RISCV_SYS_time 1062
+#define TARGET_NEWLIB_RISCV_SYS_times 153
+#define TARGET_NEWLIB_RISCV_SYS_uname 160
+#define TARGET_NEWLIB_RISCV_SYS_unlink 1026
+#define TARGET_NEWLIB_RISCV_SYS_write 64
+#define TARGET_NEWLIB_RISCV_SYS_writev 66
+
+extern CB_TARGET_DEFS_MAP cb_sh_syscall_map[];
+#define TARGET_NEWLIB_SH_SYS_ARG 24
+#define TARGET_NEWLIB_SH_SYS_argc 172
+#define TARGET_NEWLIB_SH_SYS_argn 174
+#define TARGET_NEWLIB_SH_SYS_argnlen 173
+#define TARGET_NEWLIB_SH_SYS_chdir 12
+#define TARGET_NEWLIB_SH_SYS_chmod 15
+#define TARGET_NEWLIB_SH_SYS_chown 16
+#define TARGET_NEWLIB_SH_SYS_close 6
+#define TARGET_NEWLIB_SH_SYS_creat 8
+#define TARGET_NEWLIB_SH_SYS_execv 11
+#define TARGET_NEWLIB_SH_SYS_execve 59
+#define TARGET_NEWLIB_SH_SYS_exit 1
+#define TARGET_NEWLIB_SH_SYS_fork 2
+#define TARGET_NEWLIB_SH_SYS_fstat 22
+#define TARGET_NEWLIB_SH_SYS_ftruncate 130
+#define TARGET_NEWLIB_SH_SYS_getpid 20
+#define TARGET_NEWLIB_SH_SYS_isatty 21
+#define TARGET_NEWLIB_SH_SYS_link 9
+#define TARGET_NEWLIB_SH_SYS_lseek 19
+#define TARGET_NEWLIB_SH_SYS_mknod 14
+#define TARGET_NEWLIB_SH_SYS_open 5
+#define TARGET_NEWLIB_SH_SYS_pipe 42
+#define TARGET_NEWLIB_SH_SYS_read 3
+#define TARGET_NEWLIB_SH_SYS_stat 38
+#define TARGET_NEWLIB_SH_SYS_time 23
+#define TARGET_NEWLIB_SH_SYS_truncate 129
+#define TARGET_NEWLIB_SH_SYS_unlink 10
+#define TARGET_NEWLIB_SH_SYS_utime 201
+#define TARGET_NEWLIB_SH_SYS_wait 202
+#define TARGET_NEWLIB_SH_SYS_wait4 7
+#define TARGET_NEWLIB_SH_SYS_write 4
+
+extern CB_TARGET_DEFS_MAP cb_v850_syscall_map[];
+#define TARGET_NEWLIB_V850_SYS_ARG 24
+#define TARGET_NEWLIB_V850_SYS_chdir 12
+#define TARGET_NEWLIB_V850_SYS_chmod 15
+#define TARGET_NEWLIB_V850_SYS_chown 16
+#define TARGET_NEWLIB_V850_SYS_close 6
+#define TARGET_NEWLIB_V850_SYS_creat 8
+#define TARGET_NEWLIB_V850_SYS_execv 11
+#define TARGET_NEWLIB_V850_SYS_execve 59
+#define TARGET_NEWLIB_V850_SYS_exit 1
+#define TARGET_NEWLIB_V850_SYS_fork 2
+#define TARGET_NEWLIB_V850_SYS_fstat 22
+#define TARGET_NEWLIB_V850_SYS_getpid 20
+#define TARGET_NEWLIB_V850_SYS_gettimeofday 116
+#define TARGET_NEWLIB_V850_SYS_isatty 21
+#define TARGET_NEWLIB_V850_SYS_link 9
+#define TARGET_NEWLIB_V850_SYS_lseek 19
+#define TARGET_NEWLIB_V850_SYS_mknod 14
+#define TARGET_NEWLIB_V850_SYS_open 5
+#define TARGET_NEWLIB_V850_SYS_pipe 42
+#define TARGET_NEWLIB_V850_SYS_read 3
+#define TARGET_NEWLIB_V850_SYS_rename 134
+#define TARGET_NEWLIB_V850_SYS_stat 38
+#define TARGET_NEWLIB_V850_SYS_time 23
+#define TARGET_NEWLIB_V850_SYS_times 43
+#define TARGET_NEWLIB_V850_SYS_unlink 10
+#define TARGET_NEWLIB_V850_SYS_utime 201
+#define TARGET_NEWLIB_V850_SYS_wait 202
+#define TARGET_NEWLIB_V850_SYS_wait4 7
+#define TARGET_NEWLIB_V850_SYS_write 4
+
+extern CB_TARGET_DEFS_MAP cb_init_syscall_map[];
+#define TARGET_NEWLIB_SYS_argc 22
+#define TARGET_NEWLIB_SYS_argn 24
+#define TARGET_NEWLIB_SYS_argnlen 23
+#define TARGET_NEWLIB_SYS_argv 13
+#define TARGET_NEWLIB_SYS_argvlen 12
+#define TARGET_NEWLIB_SYS_chdir 14
+#define TARGET_NEWLIB_SYS_chmod 16
+#define TARGET_NEWLIB_SYS_close 3
+#define TARGET_NEWLIB_SYS_exit 1
+#define TARGET_NEWLIB_SYS_fstat 10
+#define TARGET_NEWLIB_SYS_getpid 8
+#define TARGET_NEWLIB_SYS_gettimeofday 19
+#define TARGET_NEWLIB_SYS_kill 9
+#define TARGET_NEWLIB_SYS_link 21
+#define TARGET_NEWLIB_SYS_lseek 6
+#define TARGET_NEWLIB_SYS_open 2
+#define TARGET_NEWLIB_SYS_read 4
+#define TARGET_NEWLIB_SYS_reconfig 25
+#define TARGET_NEWLIB_SYS_stat 15
+#define TARGET_NEWLIB_SYS_time 18
+#define TARGET_NEWLIB_SYS_times 20
+#define TARGET_NEWLIB_SYS_unlink 7
+#define TARGET_NEWLIB_SYS_utime 17
+#define TARGET_NEWLIB_SYS_write 5
+  /* gennltvals: END */
+
+#endif
diff --git a/sim/ppc/Makefile.in b/sim/ppc/Makefile.in
index b9918954f37e..33d7df953b59 100644
--- a/sim/ppc/Makefile.in
+++ b/sim/ppc/Makefile.in
@@ -411,9 +411,6 @@ SUPPORT_H = \
         support.h \
         support.c
 
-TARG_VALS_H = \
-        targ-vals.h
-
 INLINE = \
 	inline.h \
 	inline.c
@@ -429,8 +426,7 @@ BUILT_SRC_WO_CONFIG = \
 	support.h support.c \
 	pk.h \
 	hw.h hw.c \
-	filter_host.c \
-	targ-vals.h targ-map.c targ-vals.def
+	filter_host.c
 
 BUILT_SRC = \
 	$(BUILT_SRC_WO_CONFIG) \
@@ -473,6 +469,7 @@ COMMON_OBJS_NAMES = \
 	target-newlib-errno.o \
 	target-newlib-open.o \
 	target-newlib-signal.o \
+	target-newlib-syscall.o \
 	version.o
 COMMON_OBJS = $(COMMON_OBJS_NAMES:%=../common/common_libcommon_a-%)
 
@@ -515,7 +512,7 @@ LIB_OBJ = \
 	options.o
 
 
-GDB_OBJ = gdb-sim.o sim_calls.o targ-map.o
+GDB_OBJ = gdb-sim.o sim_calls.o
 
 HW_SRC = @sim_hw_src@
 HW_OBJ = @sim_hw_obj@
@@ -598,30 +595,6 @@ itable.o: itable.c $(ITABLE_H)
 
 mon.o: mon.c $(BASICS_H) $(CPU_H) $(MON_H)
 
-# GDB after 4.16 expects the default_callback structure to be setup.
-# As a kludge, build the common stuff here for now.
-gentmap: $(srcdir)/../common/gentmap.c Makefile targ-vals.def
-	$(ECHO_CCLD) $(LINK_FOR_BUILD) -I. -I../common -I$(srcdir)/../common \
-		$(srcdir)/../common/gentmap.c -DUSE_CONFIG_H
-
-targ-vals.def: $(srcdir)/../common/nltvals.def
-	$(ECHO_GEN) cat $(srcdir)/../common/nltvals.def > tmp-vals.def
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-vals.def targ-vals.def
-
-targ-vals.h: stamp-vals ; @true
-stamp-vals: Makefile gentmap $(srcroot)/move-if-change
-	$(ECHO_GEN) ./gentmap -h > tmp-vals.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-vals.h targ-vals.h
-	$(SILENCE) touch $@
-
-targ-map.c: stamp-map; @true
-stamp-map: Makefile gentmap $(srcroot)/move-if-change
-	$(ECHO_GEN) ./gentmap -c > tmp-map.c
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-map.c targ-map.c
-	$(SILENCE) touch $@
-
-targ-map.o: targ-map.c $(ANSIDECL_H) $(GDB_CALLBACK_H) $(TARG_VALS_H)
-
 sim-fpu.o: $(srcdir)/../common/sim-fpu.c $(CONFIG_H)
 	$(ECHO_CC) $(CC) -c $(STD_CFLAGS) -DHAVE_CONFIG_H $(srcdir)/../common/sim-fpu.c 
 
@@ -838,8 +811,7 @@ TAGS: $(BUILT_SRC)
 	etags $(srcdir)/*.h $(srcdir)/*.c $(BUILT_SRC)
 
 clean mostlyclean:
-	rm -f tmp-* *.[oasi] core psim$(EXEEXT) run$(EXEEXT) igen dgen $(BUILT_SRC_WO_CONFIG) gentmap
-	rm -f stamp-vals targ-vals.h stamp-map targ-map.c
+	rm -f tmp-* *.[oasi] core psim$(EXEEXT) run$(EXEEXT) igen dgen $(BUILT_SRC_WO_CONFIG)
 
 distclean realclean: clean
 	rm -f TAGS Makefile config.cache config.status config.h defines.h stamp-h config.log
-- 
2.33.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 2/9] sim: iq2000/lm32/m32c/moxie/rx: switch to new target-newlib-syscall.h
  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 ` Mike Frysinger
  2021-11-28  8:43 ` [PATCH 3/9] sim: v850: switch to new target-newlib-syscall Mike Frysinger
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2021-11-28  8:43 UTC (permalink / raw)
  To: gdb-patches

Use the new target-newlib-syscall.h to provide the target syscall
defines.  These code paths are written specifically for the newlib
ABI rather than being generalized, so switching them to the defines
rather than trying to go through the dynamic callback conversion
seems like the best trade-off for now.  Might have to reconsider
this in the future.
---
 sim/iq2000/iq2000.c | 16 ++++++++--------
 sim/lm32/traps.c    |  4 ++--
 sim/m32c/syscalls.c | 18 +++++++++---------
 sim/moxie/interp.c  | 12 ++++++------
 sim/rx/syscalls.c   | 20 ++++++++++----------
 5 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/sim/iq2000/iq2000.c b/sim/iq2000/iq2000.c
index 362cc4acb192..88de5ac6f5ce 100644
--- a/sim/iq2000/iq2000.c
+++ b/sim/iq2000/iq2000.c
@@ -27,7 +27,7 @@
 #include "sim-signal.h"
 #include "cgen-mem.h"
 #include "cgen-ops.h"
-#include "targ-vals.h"
+#include "target-newlib-syscall.h"
 #include <stdlib.h>
 
 enum
@@ -80,7 +80,7 @@ do_syscall (SIM_CPU *current_cpu, PCADDR pc)
 	  exit (1);
 	}
 
-    case TARGET_SYS_write:
+    case TARGET_NEWLIB_SYS_write:
       buf = zalloc (PARM3);
       sim_read (CPU_STATE (current_cpu), CPU2DATA(PARM2), buf, PARM3);
       SET_H_GR (ret_reg,
@@ -89,18 +89,18 @@ do_syscall (SIM_CPU *current_cpu, PCADDR pc)
       free (buf);
       break;
 
-    case TARGET_SYS_lseek:
+    case TARGET_NEWLIB_SYS_lseek:
       SET_H_GR (ret_reg,
 		sim_io_lseek (CPU_STATE (current_cpu),
 			      PARM1, PARM2, PARM3));
       break;
 	    
-    case TARGET_SYS_exit:
+    case TARGET_NEWLIB_SYS_exit:
       sim_engine_halt (CPU_STATE (current_cpu), current_cpu,
 		       NULL, pc, sim_exited, PARM1);
       break;
 
-    case TARGET_SYS_read:
+    case TARGET_NEWLIB_SYS_read:
       buf = zalloc (PARM3);
       SET_H_GR (ret_reg,
 		sim_io_read (CPU_STATE (current_cpu),
@@ -109,7 +109,7 @@ do_syscall (SIM_CPU *current_cpu, PCADDR pc)
       free (buf);
       break;
 	    
-    case TARGET_SYS_open:
+    case TARGET_NEWLIB_SYS_open:
       buf = fetch_str (current_cpu, pc, PARM1);
       SET_H_GR (ret_reg,
 		sim_io_open (CPU_STATE (current_cpu),
@@ -117,12 +117,12 @@ do_syscall (SIM_CPU *current_cpu, PCADDR pc)
       free (buf);
       break;
 
-    case TARGET_SYS_close:
+    case TARGET_NEWLIB_SYS_close:
       SET_H_GR (ret_reg,
 		sim_io_close (CPU_STATE (current_cpu), PARM1));
       break;
 
-    case TARGET_SYS_time:
+    case TARGET_NEWLIB_SYS_time:
       SET_H_GR (ret_reg, time (0));
       break;
 
diff --git a/sim/lm32/traps.c b/sim/lm32/traps.c
index 77b4accef4ee..87d219106458 100644
--- a/sim/lm32/traps.c
+++ b/sim/lm32/traps.c
@@ -28,7 +28,7 @@
 #include "sim-signal.h"
 #include "sim-syscall.h"
 #include "lm32-sim.h"
-#include "targ-vals.h"
+#include "target-newlib-syscall.h"
 
 /* Handle invalid instructions.  */
 
@@ -133,7 +133,7 @@ lm32bf_scall_insn (SIM_CPU * current_cpu, IADDR pc)
   host_callback *cb = STATE_CALLBACK (sd);
 
   if ((STATE_ENVIRONMENT (sd) != OPERATING_ENVIRONMENT)
-      || (GET_H_GR (8) == TARGET_SYS_exit))
+      || (GET_H_GR (8) == TARGET_NEWLIB_SYS_exit))
     {
       /* Delegate system call to host O/S.  */
       long result, result2;
diff --git a/sim/m32c/syscalls.c b/sim/m32c/syscalls.c
index e8d9d2e6cc7b..e613e5140825 100644
--- a/sim/m32c/syscalls.c
+++ b/sim/m32c/syscalls.c
@@ -32,7 +32,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "cpu.h"
 #include "mem.h"
 #include "syscalls.h"
-#include "targ-vals.h"
+#include "target-newlib-syscall.h"
 
 /* The current syscall callbacks we're using.  */
 static struct host_callback_struct *callbacks;
@@ -185,7 +185,7 @@ m32c_syscall (int id)
     printf ("\033[31m/* SYSCALL(%d) = %s */\033[0m\n", id, callnames[id]);
   switch (id)
     {
-    case TARGET_SYS_exit:
+    case TARGET_NEWLIB_SYS_exit:
       {
 	int ec = arg (2);
 	if (verbose)
@@ -194,7 +194,7 @@ m32c_syscall (int id)
       }
       break;
 
-    case TARGET_SYS_open:
+    case TARGET_NEWLIB_SYS_open:
       {
 	int path = arg (PTRSZ);
 	int oflags = arg (2);
@@ -229,7 +229,7 @@ m32c_syscall (int id)
       }
       break;
 
-    case TARGET_SYS_close:
+    case TARGET_NEWLIB_SYS_close:
       {
 	int fd = arg (2);
 
@@ -245,7 +245,7 @@ m32c_syscall (int id)
       }
       break;
 
-    case TARGET_SYS_read:
+    case TARGET_NEWLIB_SYS_read:
       {
 	int fd = arg (2);
 	int addr = arg (PTRSZ);
@@ -265,7 +265,7 @@ m32c_syscall (int id)
       }
       break;
 
-    case TARGET_SYS_write:
+    case TARGET_NEWLIB_SYS_write:
       {
 	int fd = arg (2);
 	int addr = arg (PTRSZ);
@@ -288,11 +288,11 @@ m32c_syscall (int id)
       }
       break;
 
-    case TARGET_SYS_getpid:
+    case TARGET_NEWLIB_SYS_getpid:
       put_reg (r0, 42);
       break;
 
-    case TARGET_SYS_gettimeofday:
+    case TARGET_NEWLIB_SYS_gettimeofday:
       {
 	int tvaddr = arg (PTRSZ);
 	struct timeval tv;
@@ -307,7 +307,7 @@ m32c_syscall (int id)
       }
       break;
 
-    case TARGET_SYS_kill:
+    case TARGET_NEWLIB_SYS_kill:
       {
 	int pid = arg (2);
 	int sig = arg (2);
diff --git a/sim/moxie/interp.c b/sim/moxie/interp.c
index 3aa6a3b10e0a..228e23ce803b 100644
--- a/sim/moxie/interp.c
+++ b/sim/moxie/interp.c
@@ -35,7 +35,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "sim-options.h"
 #include "sim-io.h"
 #include "sim-signal.h"
-#include "targ-vals.h"
+#include "target-newlib-syscall.h"
 
 typedef int word;
 typedef unsigned int uword;
@@ -935,13 +935,13 @@ sim_engine_run (SIM_DESC sd,
 	        cpu.asregs.sregs[3] = inum;
 		switch (inum)
 		  {
-		  case TARGET_SYS_exit:
+		  case TARGET_NEWLIB_SYS_exit:
 		    {
 		      sim_engine_halt (sd, scpu, NULL, pc, sim_exited,
 				       cpu.asregs.regs[2]);
 		      break;
 		    }
-		  case TARGET_SYS_open:
+		  case TARGET_NEWLIB_SYS_open:
 		    {
 		      char fname[1024];
 		      int mode = (int) convert_target_flags ((unsigned) cpu.asregs.regs[3]);
@@ -954,7 +954,7 @@ sim_engine_run (SIM_DESC sd,
 		      cpu.asregs.regs[2] = fd;
 		      break;
 		    }
-		  case TARGET_SYS_read:
+		  case TARGET_NEWLIB_SYS_read:
 		    {
 		      int fd = cpu.asregs.regs[2];
 		      unsigned len = (unsigned) cpu.asregs.regs[4];
@@ -965,7 +965,7 @@ sim_engine_run (SIM_DESC sd,
 		      free (buf);
 		      break;
 		    }
-		  case TARGET_SYS_write:
+		  case TARGET_NEWLIB_SYS_write:
 		    {
 		      char *str;
 		      /* String length is at 0x12($fp) */
@@ -978,7 +978,7 @@ sim_engine_run (SIM_DESC sd,
 		      cpu.asregs.regs[2] = count;
 		      break;
 		    }
-		  case TARGET_SYS_unlink:
+		  case TARGET_NEWLIB_SYS_unlink:
 		    {
 		      char fname[1024];
 		      int fd;
diff --git a/sim/rx/syscalls.c b/sim/rx/syscalls.c
index 1981b5d3c3e2..a18c1047afa0 100644
--- a/sim/rx/syscalls.c
+++ b/sim/rx/syscalls.c
@@ -32,7 +32,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "cpu.h"
 #include "mem.h"
 #include "syscalls.h"
-#include "targ-vals.h"
+#include "target-newlib-syscall.h"
 
 /* The current syscall callbacks we're using.  */
 static struct host_callback_struct *callbacks;
@@ -146,10 +146,10 @@ rx_syscall (int id)
   argp = 0;
   stackp = 4;
   if (trace)
-    printf ("\033[31m/* SYSCALL(%d) = %s */\033[0m\n", id, id <= TARGET_SYS_link ? callnames[id] : "unknown");
+    printf ("\033[31m/* SYSCALL(%d) = %s */\033[0m\n", id, id <= TARGET_NEWLIB_SYS_link ? callnames[id] : "unknown");
   switch (id)
     {
-    case TARGET_SYS_exit:
+    case TARGET_NEWLIB_SYS_exit:
       {
 	int ec = arg ();
 	if (verbose)
@@ -158,7 +158,7 @@ rx_syscall (int id)
       }
       break;
 
-    case TARGET_SYS_open:
+    case TARGET_NEWLIB_SYS_open:
       {
 	int oflags, cflags;
 	int path = arg ();
@@ -200,7 +200,7 @@ rx_syscall (int id)
       }
       break;
 
-    case TARGET_SYS_close:
+    case TARGET_NEWLIB_SYS_close:
       {
 	int fd = arg ();
 
@@ -216,7 +216,7 @@ rx_syscall (int id)
       }
       break;
 
-    case TARGET_SYS_read:
+    case TARGET_NEWLIB_SYS_read:
       {
 	int fd = arg ();
 	int addr = arg ();
@@ -236,7 +236,7 @@ rx_syscall (int id)
       }
       break;
 
-    case TARGET_SYS_write:
+    case TARGET_NEWLIB_SYS_write:
       {
 	int fd = arg ();
 	int addr = arg ();
@@ -259,11 +259,11 @@ rx_syscall (int id)
       }
       break;
 
-    case TARGET_SYS_getpid:
+    case TARGET_NEWLIB_SYS_getpid:
       put_reg (1, 42);
       break;
 
-    case TARGET_SYS_gettimeofday:
+    case TARGET_NEWLIB_SYS_gettimeofday:
       {
 	int tvaddr = arg ();
 	struct timeval tv;
@@ -278,7 +278,7 @@ rx_syscall (int id)
       }
       break;
 
-    case TARGET_SYS_kill:
+    case TARGET_NEWLIB_SYS_kill:
       {
 	int pid = arg ();
 	int sig = arg ();
-- 
2.33.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 3/9] sim: v850: switch to new target-newlib-syscall
  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
  2021-11-28  8:43 ` [PATCH 4/9] sim: sh: " Mike Frysinger
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2021-11-28  8:43 UTC (permalink / raw)
  To: gdb-patches

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 4/9] sim: sh: switch to new target-newlib-syscall
  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
  2021-11-28  8:43 ` [PATCH 5/9] sim: d10v: " Mike Frysinger
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2021-11-28  8:43 UTC (permalink / raw)
  To: gdb-patches

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 5/9] sim: d10v: switch to new target-newlib-syscall
  2021-11-28  8:43 [PATCH 1/9] sim: nltvals: pull target syscalls out into a dedicated source file Mike Frysinger
                   ` (2 preceding siblings ...)
  2021-11-28  8:43 ` [PATCH 4/9] sim: sh: " Mike Frysinger
@ 2021-11-28  8:43 ` Mike Frysinger
  2021-11-28  8:43 ` [PATCH 6/9] sim: cr16: " Mike Frysinger
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2021-11-28  8:43 UTC (permalink / raw)
  To: gdb-patches

Use the new target-newlib-syscall module.  This is needed to merge all
the architectures into a single build, and d10v 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/d10v/Makefile.in |  5 +---
 sim/d10v/interp.c    |  3 +++
 sim/d10v/simops.c    | 54 ++++++++++++++++++--------------------------
 3 files changed, 26 insertions(+), 36 deletions(-)

diff --git a/sim/d10v/Makefile.in b/sim/d10v/Makefile.in
index 51fb9eb72d1a..cba370e9e0fa 100644
--- a/sim/d10v/Makefile.in
+++ b/sim/d10v/Makefile.in
@@ -27,10 +27,7 @@ SIM_OBJS = \
 
 SIM_EXTRA_DEPS = simops.h
 
-INCLUDE = d10v_sim.h $(srcroot)/include/sim/callback.h targ-vals.h endian.c \
+INCLUDE = d10v_sim.h $(srcroot)/include/sim/callback.h endian.c \
 	$(srcroot)/include/gdb/sim-d10v.h
 
-# This selects the d10v newlib/libgloss syscall definitions.
-NL_TARGET = -DNL_TARGET_d10v
-
 ## COMMON_POST_CONFIG_FRAG
diff --git a/sim/d10v/interp.c b/sim/d10v/interp.c
index 33baea79d794..2a0cf6bc3a01 100644
--- a/sim/d10v/interp.c
+++ b/sim/d10v/interp.c
@@ -18,6 +18,8 @@
 #include <stdlib.h>
 #include <assert.h>
 
+#include "target-newlib-syscall.h"
+
 enum _leftright { LEFT_FIRST, RIGHT_FIRST };
 
 struct _state State;
@@ -758,6 +760,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_d10v_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/d10v/simops.c b/sim/d10v/simops.c
index 64c888c4c429..6e6bb0209dd4 100644
--- a/sim/d10v/simops.c
+++ b/sim/d10v/simops.c
@@ -13,7 +13,7 @@
 #include "sim-main.h"
 #include "sim-signal.h"
 #include "simops.h"
-#include "targ-vals.h"
+#include "target-newlib-syscall.h"
 
 #define EXCEPTION(sig) sim_engine_halt (sd, cpu, NULL, PC, sim_stopped, sig)
 
@@ -3207,20 +3207,20 @@ OP_5F00 (SIM_DESC sd, SIM_CPU *cpu)
 	switch (FUNC)
 	  {
 #if !defined(__GO32__) && !defined(_WIN32)
-	  case TARGET_SYS_fork:
+	  case TARGET_NEWLIB_D10V_SYS_fork:
 	    trace_input ("<fork>", OP_VOID, OP_VOID, OP_VOID);
 	    RETVAL (fork ());
 	    trace_output_16 (sd, result);
 	    break;
 
 #define getpid() 47
-	  case TARGET_SYS_getpid:
+	  case TARGET_NEWLIB_D10V_SYS_getpid:
 	    trace_input ("<getpid>", OP_VOID, OP_VOID, OP_VOID);
 	    RETVAL (getpid ());
 	    trace_output_16 (sd, result);
 	    break;
 
-	  case TARGET_SYS_kill:
+	  case TARGET_NEWLIB_D10V_SYS_kill:
 	    trace_input ("<kill>", OP_R0, OP_R1, OP_VOID);
 	    if (PARM1 == getpid ())
 	      {
@@ -3348,22 +3348,20 @@ OP_5F00 (SIM_DESC sd, SIM_CPU *cpu)
 	      }
 	    break;
 
-	  case TARGET_SYS_execve:
+	  case TARGET_NEWLIB_D10V_SYS_execve:
 	    trace_input ("<execve>", OP_R0, OP_R1, OP_R2);
 	    RETVAL (execve (MEMPTR (PARM1), (char **) MEMPTR (PARM2),
 			     (char **)MEMPTR (PARM3)));
 	    trace_output_16 (sd, result);
 	    break;
 
-#ifdef TARGET_SYS_execv
-	  case TARGET_SYS_execv:
+	  case TARGET_NEWLIB_D10V_SYS_execv:
 	    trace_input ("<execv>", OP_R0, OP_R1, OP_VOID);
 	    RETVAL (execve (MEMPTR (PARM1), (char **) MEMPTR (PARM2), NULL));
 	    trace_output_16 (sd, result);
 	    break;
-#endif
 
-	  case TARGET_SYS_pipe:
+	  case TARGET_NEWLIB_D10V_SYS_pipe:
 	    {
 	      reg_t buf;
 	      int host_fd[2];
@@ -3379,8 +3377,7 @@ OP_5F00 (SIM_DESC sd, SIM_CPU *cpu)
 	  break;
 
 #if 0
-#ifdef TARGET_SYS_wait
-	  case TARGET_SYS_wait:
+	  case TARGET_NEWLIB_D10V_SYS_wait:
 	    {
 	      int status;
 	      trace_input ("<wait>", OP_R0, OP_VOID, OP_VOID);
@@ -3391,28 +3388,27 @@ OP_5F00 (SIM_DESC sd, SIM_CPU *cpu)
 	    }
 	  break;
 #endif
-#endif
 #else
-	  case TARGET_SYS_getpid:
+	  case TARGET_NEWLIB_D10V_SYS_getpid:
 	    trace_input ("<getpid>", OP_VOID, OP_VOID, OP_VOID);
 	    RETVAL (1);
 	    trace_output_16 (sd, result);
 	    break;
 
-	  case TARGET_SYS_kill:
+	  case TARGET_NEWLIB_D10V_SYS_kill:
 	    trace_input ("<kill>", OP_REG, OP_REG, OP_VOID);
 	    trace_output_void (sd);
 	    sim_engine_halt (sd, cpu, NULL, PC, sim_stopped, PARM2);
 	    break;
 #endif
 
-	  case TARGET_SYS_read:
+	  case TARGET_NEWLIB_D10V_SYS_read:
 	    trace_input ("<read>", OP_R0, OP_R1, OP_R2);
 	    RETVAL (cb->read (cb, PARM1, MEMPTR (PARM2), PARM3));
 	    trace_output_16 (sd, result);
 	    break;
 
-	  case TARGET_SYS_write:
+	  case TARGET_NEWLIB_D10V_SYS_write:
 	    trace_input ("<write>", OP_R0, OP_R1, OP_R2);
 	    if (PARM1 == 1)
 	      RETVAL ((int)cb->write_stdout (cb, MEMPTR (PARM2), PARM3));
@@ -3421,7 +3417,7 @@ OP_5F00 (SIM_DESC sd, SIM_CPU *cpu)
 	    trace_output_16 (sd, result);
 	    break;
 
-	  case TARGET_SYS_lseek:
+	  case TARGET_NEWLIB_D10V_SYS_lseek:
 	    trace_input ("<lseek>", OP_R0, OP_R1, OP_R2);
 	    RETVAL32 (cb->lseek (cb, PARM1,
 				 ((((unsigned long) PARM2) << 16)
@@ -3430,26 +3426,25 @@ OP_5F00 (SIM_DESC sd, SIM_CPU *cpu)
 	    trace_output_32 (sd, result);
 	    break;
 
-	  case TARGET_SYS_close:
+	  case TARGET_NEWLIB_D10V_SYS_close:
 	    trace_input ("<close>", OP_R0, OP_VOID, OP_VOID);
 	    RETVAL (cb->close (cb, PARM1));
 	    trace_output_16 (sd, result);
 	    break;
 
-	  case TARGET_SYS_open:
+	  case TARGET_NEWLIB_D10V_SYS_open:
 	    trace_input ("<open>", OP_R0, OP_R1, OP_R2);
 	    RETVAL (cb->open (cb, MEMPTR (PARM1), PARM2));
 	    trace_output_16 (sd, result);
 	    break;
 
-	  case TARGET_SYS_exit:
+	  case TARGET_NEWLIB_D10V_SYS_exit:
 	    trace_input ("<exit>", OP_R0, OP_VOID, OP_VOID);
 	    trace_output_void (sd);
 	    sim_engine_halt (sd, cpu, NULL, PC, sim_exited, GPR (0));
 	    break;
 
-#ifdef TARGET_SYS_stat
-	  case TARGET_SYS_stat:
+	  case TARGET_NEWLIB_D10V_SYS_stat:
 	    trace_input ("<stat>", OP_R0, OP_R1, OP_VOID);
 	    /* stat system call */
 	    {
@@ -3477,23 +3472,21 @@ OP_5F00 (SIM_DESC sd, SIM_CPU *cpu)
 	    }
 	    trace_output_16 (sd, result);
 	    break;
-#endif
 
-	  case TARGET_SYS_chown:
+	  case TARGET_NEWLIB_D10V_SYS_chown:
 	    trace_input ("<chown>", OP_R0, OP_R1, OP_R2);
 	    RETVAL (chown (MEMPTR (PARM1), PARM2, PARM3));
 	    trace_output_16 (sd, result);
 	    break;
 
-	  case TARGET_SYS_chmod:
+	  case TARGET_NEWLIB_D10V_SYS_chmod:
 	    trace_input ("<chmod>", OP_R0, OP_R1, OP_R2);
 	    RETVAL (chmod (MEMPTR (PARM1), PARM2));
 	    trace_output_16 (sd, result);
 	    break;
 
 #if 0
-#ifdef TARGET_SYS_utime
-	  case TARGET_SYS_utime:
+	  case TARGET_NEWLIB_D10V_SYS_utime:
 	    trace_input ("<utime>", OP_R0, OP_R1, OP_R2);
 	    /* Cast the second argument to void *, to avoid type mismatch
 	       if a prototype is present.  */
@@ -3501,18 +3494,15 @@ OP_5F00 (SIM_DESC sd, SIM_CPU *cpu)
 	    trace_output_16 (sd, result);
 	    break;
 #endif
-#endif
 
 #if 0
-#ifdef TARGET_SYS_time
-	  case TARGET_SYS_time:
+	  case TARGET_NEWLIB_D10V_SYS_time:
 	    trace_input ("<time>", OP_R0, OP_R1, OP_R2);
 	    RETVAL32 (time (PARM1 ? MEMPTR (PARM1) : NULL));
 	    trace_output_32 (sd, result);
 	    break;
 #endif
-#endif
-	    
+
 	  default:
 	    cb->error (cb, "Unknown syscall %d", FUNC);
 	  }
-- 
2.33.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 6/9] sim: cr16: switch to new target-newlib-syscall
  2021-11-28  8:43 [PATCH 1/9] sim: nltvals: pull target syscalls out into a dedicated source file Mike Frysinger
                   ` (3 preceding siblings ...)
  2021-11-28  8:43 ` [PATCH 5/9] sim: d10v: " Mike Frysinger
@ 2021-11-28  8:43 ` Mike Frysinger
  2021-11-28  8:43 ` [PATCH 7/9] sim: riscv: " Mike Frysinger
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2021-11-28  8:43 UTC (permalink / raw)
  To: gdb-patches

Use the new target-newlib-syscall module.  This is needed to merge all
the architectures into a single build, and cr16 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/cr16/Makefile.in |  3 --
 sim/cr16/interp.c    |  3 ++
 sim/cr16/simops.c    | 73 +++++++++++++++-----------------------------
 3 files changed, 28 insertions(+), 51 deletions(-)

diff --git a/sim/cr16/Makefile.in b/sim/cr16/Makefile.in
index 4d7345a6b516..26f65a0384f7 100644
--- a/sim/cr16/Makefile.in
+++ b/sim/cr16/Makefile.in
@@ -26,7 +26,4 @@ SIM_OBJS = \
 
 SIM_EXTRA_DEPS = simops.h
 
-# This selects the cr16 newlib/libgloss syscall definitions.
-NL_TARGET = -DNL_TARGET_cr16
-
 ## COMMON_POST_CONFIG_FRAG
diff --git a/sim/cr16/interp.c b/sim/cr16/interp.c
index 18e1db9f7392..d63dca50c49b 100644
--- a/sim/cr16/interp.c
+++ b/sim/cr16/interp.c
@@ -36,6 +36,8 @@
 #include "gdb/signals.h"
 #include "opcode/cr16.h"
 
+#include "target-newlib-syscall.h"
+
 struct _state State;
 
 int cr16_debug;
@@ -400,6 +402,7 @@ sim_open (SIM_OPEN_KIND kind, struct host_callback_struct *cb,
 
   /* Set default options before parsing user options.  */
   current_target_byte_order = BFD_ENDIAN_LITTLE;
+  cb->syscall_map = cb_cr16_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/cr16/simops.c b/sim/cr16/simops.c
index afd870e595fa..75962bfe37ca 100644
--- a/sim/cr16/simops.c
+++ b/sim/cr16/simops.c
@@ -34,14 +34,12 @@
 #include "sim-main.h"
 #include "sim-signal.h"
 #include "simops.h"
-#include "targ-vals.h"
+#include "target-newlib-syscall.h"
 
-#ifdef TARGET_SYS_utime
+#ifdef HAVE_UTIME_H
 #include <utime.h>
 #endif
-#ifdef TARGET_SYS_wait
 #include <sys/wait.h>
-#endif
 
 #define EXCEPTION(sig) sim_engine_halt (sd, cpu, NULL, PC, sim_stopped, sig)
 
@@ -5123,22 +5121,20 @@ OP_C_C (SIM_DESC sd, SIM_CPU *cpu)
 	switch (FUNC)
 	  {
 #if !defined(__GO32__) && !defined(_WIN32)
-#ifdef TARGET_SYS_fork
-	  case TARGET_SYS_fork:
+	  case TARGET_NEWLIB_CR16_SYS_fork:
 	    trace_input ("<fork>", OP_VOID, OP_VOID, OP_VOID);
 	    RETVAL (fork ());
 	    trace_output_16 (sd, result);
 	    break;
-#endif
 
 #define getpid() 47
-	  case TARGET_SYS_getpid:
+	  case TARGET_NEWLIB_CR16_SYS_getpid:
 	    trace_input ("<getpid>", OP_VOID, OP_VOID, OP_VOID);
 	    RETVAL (getpid ());
 	    trace_output_16 (sd, result);
 	    break;
 
-	  case TARGET_SYS_kill:
+	  case TARGET_NEWLIB_CR16_SYS_kill:
 	    trace_input ("<kill>", OP_REG, OP_REG, OP_VOID);
 	    if (PARM1 == getpid ())
 	      {
@@ -5266,25 +5262,20 @@ OP_C_C (SIM_DESC sd, SIM_CPU *cpu)
 	      }
 	    break;
 
-#ifdef TARGET_SYS_execve
-	  case TARGET_SYS_execve:
+	  case TARGET_NEWLIB_CR16_SYS_execve:
 	    trace_input ("<execve>", OP_VOID, OP_VOID, OP_VOID);
 	    RETVAL (execve (MEMPTR (PARM1), (char **) MEMPTR (PARM2<<16|PARM3),
 			     (char **)MEMPTR (PARM4)));
 	    trace_output_16 (sd, result);
 	    break;
-#endif
 
-#ifdef TARGET_SYS_execv
-	  case TARGET_SYS_execv:
+	  case TARGET_NEWLIB_CR16_SYS_execv:
 	    trace_input ("<execv>", OP_VOID, OP_VOID, OP_VOID);
 	    RETVAL (execve (MEMPTR (PARM1), (char **) MEMPTR (PARM2), NULL));
 	    trace_output_16 (sd, result);
 	    break;
-#endif
 
-#ifdef TARGET_SYS_pipe
-	  case TARGET_SYS_pipe:
+	  case TARGET_NEWLIB_CR16_SYS_pipe:
 	    {
 	      reg_t buf;
 	      int host_fd[2];
@@ -5298,10 +5289,8 @@ OP_C_C (SIM_DESC sd, SIM_CPU *cpu)
 	      trace_output_16 (sd, result);
 	    }
 	  break;
-#endif
 
-#ifdef TARGET_SYS_wait
-	  case TARGET_SYS_wait:
+	  case TARGET_NEWLIB_CR16_SYS_wait:
 	    {
 	      int status;
 	      trace_input ("<wait>", OP_REG, OP_VOID, OP_VOID);
@@ -5311,22 +5300,21 @@ OP_C_C (SIM_DESC sd, SIM_CPU *cpu)
 	      trace_output_16 (sd, result);
 	    }
 	  break;
-#endif
 #else
-	  case TARGET_SYS_getpid:
+	  case TARGET_NEWLIB_CR16_SYS_getpid:
 	    trace_input ("<getpid>", OP_VOID, OP_VOID, OP_VOID);
 	    RETVAL (1);
 	    trace_output_16 (sd, result);
 	    break;
 
-	  case TARGET_SYS_kill:
+	  case TARGET_NEWLIB_CR16_SYS_kill:
 	    trace_input ("<kill>", OP_REG, OP_REG, OP_VOID);
 	    trace_output_void (sd);
 	    EXCEPTION (PARM2);
 	    break;
 #endif
 
-	  case TARGET_SYS_read:
+	  case TARGET_NEWLIB_CR16_SYS_read:
 	    trace_input ("<read>", OP_REG, OP_MEMREF, OP_REG);
 	    RETVAL (cb->read (cb, PARM1,
 			      MEMPTR (((unsigned long)PARM3 << 16)
@@ -5334,7 +5322,7 @@ OP_C_C (SIM_DESC sd, SIM_CPU *cpu)
 	    trace_output_16 (sd, result);
 	    break;
 
-	  case TARGET_SYS_write:
+	  case TARGET_NEWLIB_CR16_SYS_write:
 	    trace_input ("<write>", OP_REG, OP_MEMREF, OP_REG);
 	    RETVAL ((int)cb->write (cb, PARM1,
 				    MEMPTR (((unsigned long)PARM3 << 16)
@@ -5342,34 +5330,32 @@ OP_C_C (SIM_DESC sd, SIM_CPU *cpu)
 	    trace_output_16 (sd, result);
 	    break;
 
-	  case TARGET_SYS_lseek:
+	  case TARGET_NEWLIB_CR16_SYS_lseek:
 	    trace_input ("<lseek>", OP_REG, OP_REGP, OP_REG);
 	    RETVAL32 (cb->lseek (cb, PARM1, ((((long) PARM3) << 16) | PARM2),
 				 PARM4));
 	    trace_output_32 (sd, result);
 	    break;
 
-	  case TARGET_SYS_close:
+	  case TARGET_NEWLIB_CR16_SYS_close:
 	    trace_input ("<close>", OP_REG, OP_VOID, OP_VOID);
 	    RETVAL (cb->close (cb, PARM1));
 	    trace_output_16 (sd, result);
 	    break;
 
-	  case TARGET_SYS_open:
+	  case TARGET_NEWLIB_CR16_SYS_open:
 	    trace_input ("<open>", OP_MEMREF, OP_REG, OP_VOID);
 	    RETVAL32 (cb->open (cb, MEMPTR ((((unsigned long)PARM2) << 16)
 					    | PARM1), PARM3));
 	    trace_output_32 (sd, result);
 	    break;
 
-#ifdef TARGET_SYS_rename
-	  case TARGET_SYS_rename:
+	  case TARGET_NEWLIB_CR16_SYS_rename:
 	    trace_input ("<rename>", OP_MEMREF, OP_MEMREF, OP_VOID);
 	    RETVAL (cb->rename (cb, MEMPTR ((((unsigned long)PARM2) << 16) | PARM1),
 				    MEMPTR ((((unsigned long)PARM4) << 16) | PARM3)));
 	    trace_output_16 (sd, result);
 	    break;
-#endif
 
 	  case 0x408: /* REVISIT: Added a dummy getenv call. */
 	    trace_input ("<getenv>", OP_MEMREF, OP_MEMREF, OP_VOID);
@@ -5377,21 +5363,19 @@ OP_C_C (SIM_DESC sd, SIM_CPU *cpu)
 	    trace_output_32 (sd, result);
 	    break;
 
-	  case TARGET_SYS_exit:
+	  case TARGET_NEWLIB_CR16_SYS_exit:
 	    trace_input ("<exit>", OP_VOID, OP_VOID, OP_VOID);
 	    trace_output_void (sd);
 	    sim_engine_halt (sd, cpu, NULL, PC, sim_exited, GPR (2));
 	    break;
 
-	  case TARGET_SYS_unlink:
+	  case TARGET_NEWLIB_CR16_SYS_unlink:
 	    trace_input ("<unlink>", OP_MEMREF, OP_VOID, OP_VOID);
 	    RETVAL (cb->unlink (cb, MEMPTR (((unsigned long)PARM2 << 16) | PARM1)));
 	    trace_output_16 (sd, result);
 	    break;
 
-
-#ifdef TARGET_SYS_stat
-	  case TARGET_SYS_stat:
+	  case TARGET_NEWLIB_CR16_SYS_stat:
 	    trace_input ("<stat>", OP_VOID, OP_VOID, OP_VOID);
 	    /* stat system call.  */
 	    {
@@ -5419,40 +5403,33 @@ OP_C_C (SIM_DESC sd, SIM_CPU *cpu)
 	    }
 	    trace_output_16 (sd, result);
 	    break;
-#endif
 
-#ifdef TARGET_SYS_chown
-	  case TARGET_SYS_chown:
+	  case TARGET_NEWLIB_CR16_SYS_chown:
 	    trace_input ("<chown>", OP_VOID, OP_VOID, OP_VOID);
 	    RETVAL (chown (MEMPTR (PARM1), PARM2, PARM3));
 	    trace_output_16 (sd, result);
 	    break;
-#endif
 
-	  case TARGET_SYS_chmod:
+	  case TARGET_NEWLIB_CR16_SYS_chmod:
 	    trace_input ("<chmod>", OP_VOID, OP_VOID, OP_VOID);
 	    RETVAL (chmod (MEMPTR (PARM1), PARM2));
 	    trace_output_16 (sd, result);
 	    break;
 
-#ifdef TARGET_SYS_utime
-	  case TARGET_SYS_utime:
+	  case TARGET_NEWLIB_CR16_SYS_utime:
 	    trace_input ("<utime>", OP_REG, OP_REG, OP_REG);
 	    /* Cast the second argument to void *, to avoid type mismatch
 	       if a prototype is present.  */
 	    RETVAL (utime (MEMPTR (PARM1), (void *) MEMPTR (PARM2)));
 	    trace_output_16 (sd, result);
 	    break;
-#endif
 
-#ifdef TARGET_SYS_time
-	  case TARGET_SYS_time:
+	  case TARGET_NEWLIB_CR16_SYS_time:
 	    trace_input ("<time>", OP_VOID, OP_VOID, OP_REG);
 	    RETVAL32 (time (NULL));
 	    trace_output_32 (sd, result);
 	    break;
-#endif
-	    
+
 	  default:
 	    a = OP[0];
 	    switch (a)
-- 
2.33.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 7/9] sim: riscv: switch to new target-newlib-syscall
  2021-11-28  8:43 [PATCH 1/9] sim: nltvals: pull target syscalls out into a dedicated source file Mike Frysinger
                   ` (4 preceding siblings ...)
  2021-11-28  8:43 ` [PATCH 6/9] sim: cr16: " Mike Frysinger
@ 2021-11-28  8:43 ` 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
  7 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2021-11-28  8:43 UTC (permalink / raw)
  To: gdb-patches

Use the new target-newlib-syscall module.  This is needed to merge all
the architectures into a single build, and riscv has a custom syscall
table for its newlib/libgloss port.
---
 sim/riscv/Makefile.in | 3 ---
 sim/riscv/interp.c    | 2 ++
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/sim/riscv/Makefile.in b/sim/riscv/Makefile.in
index 17cb288eba3d..b967654d7875 100644
--- a/sim/riscv/Makefile.in
+++ b/sim/riscv/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_riscv
-
 ## COMMON_PRE_CONFIG_FRAG
 
 SIM_OBJS = \
diff --git a/sim/riscv/interp.c b/sim/riscv/interp.c
index efa4b5669cb3..13fe6c7cae0d 100644
--- a/sim/riscv/interp.c
+++ b/sim/riscv/interp.c
@@ -24,6 +24,7 @@
 #include "sim/callback.h"
 #include "sim-main.h"
 #include "sim-options.h"
+#include "target-newlib-syscall.h"
 \f
 void
 sim_engine_run (SIM_DESC sd,
@@ -69,6 +70,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback,
   STATE_MACHS (sd) = riscv_sim_machs;
   STATE_MODEL_NAME (sd) = WITH_TARGET_WORD_BITSIZE == 32 ? "RV32G" : "RV64G";
   current_target_byte_order = BFD_ENDIAN_LITTLE;
+  callback->syscall_map = cb_riscv_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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 8/9] sim: mcore: switch to new target-newlib-syscall
  2021-11-28  8:43 [PATCH 1/9] sim: nltvals: pull target syscalls out into a dedicated source file Mike Frysinger
                   ` (5 preceding siblings ...)
  2021-11-28  8:43 ` [PATCH 7/9] sim: riscv: " Mike Frysinger
@ 2021-11-28  8:43 ` Mike Frysinger
  2021-11-28  8:43 ` [PATCH 9/9] sim: drop unused gentmap & nltvals.def logic Mike Frysinger
  7 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2021-11-28  8:43 UTC (permalink / raw)
  To: gdb-patches

Use the new target-newlib-syscall module.  This is needed to merge all
the architectures into a single build, and mcore has a custom syscall
table for its newlib/libgloss port.
---
 sim/mcore/Makefile.in | 3 ---
 sim/mcore/interp.c    | 5 +++++
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/sim/mcore/Makefile.in b/sim/mcore/Makefile.in
index 45cf634d06a1..8f625839723a 100644
--- a/sim/mcore/Makefile.in
+++ b/sim/mcore/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 bfin newlib/libgloss syscall definitions.
-NL_TARGET = -DNL_TARGET_mcore
-
 ## COMMON_PRE_CONFIG_FRAG
 
 SIM_OBJS = \
diff --git a/sim/mcore/interp.c b/sim/mcore/interp.c
index e8a452022192..bc33cc0d450c 100644
--- a/sim/mcore/interp.c
+++ b/sim/mcore/interp.c
@@ -36,6 +36,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "sim-syscall.h"
 #include "sim-options.h"
 
+#include "target-newlib-syscall.h"
+
 #define target_big_endian (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN)
 
 
@@ -1350,6 +1352,9 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
   SIM_DESC sd = sim_state_alloc (kind, cb);
   SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
 
+  /* Set default options before parsing user options.  */
+  cb->syscall_map = cb_mcore_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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 9/9] sim: drop unused gentmap & nltvals.def logic
  2021-11-28  8:43 [PATCH 1/9] sim: nltvals: pull target syscalls out into a dedicated source file Mike Frysinger
                   ` (6 preceding siblings ...)
  2021-11-28  8:43 ` [PATCH 8/9] sim: mcore: " Mike Frysinger
@ 2021-11-28  8:43 ` Mike Frysinger
  7 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2021-11-28  8:43 UTC (permalink / raw)
  To: gdb-patches

Now that all ports have switched to target-newlib-* files, there's
no need for these files & generating things at build time.  So punt
the logic and make target-newlib-syscall a hard requirement.
---
 sim/.gitignore            |   2 -
 sim/common/Make-common.in |  38 +-----
 sim/common/gennltvals.py  |  84 +++++--------
 sim/common/gentmap.c      |  79 ------------
 sim/common/nltvals.def    | 248 --------------------------------------
 sim/mips/Makefile.in      |   2 +-
 6 files changed, 31 insertions(+), 422 deletions(-)
 delete mode 100644 sim/common/gentmap.c
 delete mode 100644 sim/common/nltvals.def

diff --git a/sim/.gitignore b/sim/.gitignore
index 0ba781c22346..bcccc0232a94 100644
--- a/sim/.gitignore
+++ b/sim/.gitignore
@@ -1,7 +1,5 @@
 ChangeLog
 
-/*/gentmap
 /*/run
 /*/hw-config.h
-/*/targ-*
 /*/version.c
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index f834edbec8a8..2d4159393ac5 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -235,18 +235,12 @@ COMMON_OBJS_NAMES = \
 	target-newlib-errno.o \
 	target-newlib-open.o \
 	target-newlib-signal.o \
+	target-newlib-syscall.o \
 	version.o
 COMMON_OBJS = $(COMMON_OBJS_NAMES:%=../common/common_libcommon_a-%)
 
 LIB_OBJS = modules.o syscall.o $(COMMON_OBJS) $(SIM_OBJS)
 
-# TODO: Migrate everyone to target-newlib-syscall.o.
-ifeq ($(NL_TARGET),)
-COMMON_OBJS_NAMES += target-newlib-syscall.o
-else
-LIB_OBJS += targ-map.o
-endif
-
 COMPILE_FOR_BUILD = $(CC_FOR_BUILD) $(BUILD_CFLAGS)
 LINK_FOR_BUILD = $(CC_FOR_BUILD) $(BUILD_CFLAGS) $(LDFLAGS_FOR_BUILD) -o $@
 
@@ -266,29 +260,6 @@ run$(EXEEXT): $(SIM_RUN_OBJS) libsim.a $(LIBDEPS)
 	$(ECHO_CCLD) $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o run$(EXEEXT) \
 	  $(SIM_RUN_OBJS) libsim.a $(EXTRA_LIBS)
 
-# FIXME: Ideally, callback.o and friends live in a library outside of
-# both the gdb and simulator source trees (e.g. devo/remote.  Not
-# devo/libremote because this directory would contain more than just
-# a library).
-
-gentmap.o: Makefile $(srccom)/gentmap.c $(srccom)/nltvals.def
-	$(ECHO_CC) $(COMPILE_FOR_BUILD) -o $@ -c $(srccom)/gentmap.c $(NL_TARGET)
-
-gentmap: gentmap.o
-	$(ECHO_CC) $(LINK_FOR_BUILD) $<
-
-targ-vals.h targ-map.c: stamp-tvals
-stamp-tvals: gentmap
-	$(ECHO_STAMP) targ-vals.h
-	$(SILENCE) ./gentmap -h >tmp-tvals.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-tvals.h targ-vals.h
-ifneq ($(NL_TARGET),)
-	$(ECHO_STAMP) targ-tmap.c
-	$(SILENCE) ./gentmap -c >tmp-tmap.c
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-tmap.c targ-map.c
-endif
-	$(SILENCE) touch $@
-
 #
 # Rules for building sim-* components.  Triggered by listing the corresponding
 # .o file in the list of simulator targets.
@@ -413,11 +384,7 @@ all_object_files = $(LIB_OBJS) $(SIM_RUN_OBJS)
 generated_files = \
 	$(SIM_EXTRA_DEPS) \
 	hw-config.h \
-	modules.c \
-	targ-vals.h
-ifneq ($(NL_TARGET),)
-generated_files += targ-map.c
-endif
+	modules.c
 
 # Ensure that generated files are created early.  Use order-only
 # dependencies if available.  They require GNU make 3.80 or newer,
@@ -532,7 +499,6 @@ mostlyclean clean: $(SIM_EXTRA_CLEAN)
 		run$(EXEEXT) libsim.a \
 		hw-config.h stamp-hw \
 		modules.c stamp-modules \
-		gentmap targ-map.c targ-vals.h stamp-tvals \
 		tmp-mloop.hin tmp-mloop.h tmp-mloop.cin tmp-mloop.c
 
 distclean maintainer-clean realclean: clean $(SIM_EXTRA_DISTCLEAN)
diff --git a/sim/common/gennltvals.py b/sim/common/gennltvals.py
index 1e98691cb3d5..3f2422c42160 100755
--- a/sim/common/gennltvals.py
+++ b/sim/common/gennltvals.py
@@ -16,9 +16,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/>.
 
-"""Helper to generate nltvals.def.
+"""Helper to generate target-newlib-* files.
 
-nltvals.def is a file that describes various newlib/libgloss target values used
+target-newlib-* are files that describe various newlib/libgloss values used
 by the host/target interface.  This needs to be rerun whenever the newlib source
 changes.  Developers manually run it.
 
@@ -99,7 +99,7 @@ def extract_syms(cpp: str, srcdir: Path,
     return ret
 
 
-def gentvals(output_dir: Path, output: TextIO,
+def gentvals(output_dir: Path,
              cpp: str, srctype: str, srcdir: Path,
              headers: Iterable[str],
              pattern: str,
@@ -118,62 +118,37 @@ def gentvals(output_dir: Path, output: TextIO,
 
     syms = extract_syms(cpp, srcdir, headers, pattern, filter)
 
-    # If we have a map file, use it directly.
     target_map = output_dir / f'target-newlib-{srctype}.c'
-    if target_map.exists():
-        old_lines = target_map.read_text().splitlines()
-        start_i = end_i = None
-        for i, line in enumerate(old_lines):
-            if START_MARKER in line:
-                start_i = i
-            if END_MARKER in line:
-                end_i = i
-        assert start_i and end_i
-        new_lines = old_lines[0:start_i + 1]
-        new_lines.extend(
-            f'#ifdef {sym}\n'
-            f'  {{ "{sym}", {sym}, {val} }},\n'
-            f'#endif' for sym, val in sorted(syms.items()))
-        new_lines.extend(old_lines[end_i:])
-        target_map.write_text('\n'.join(new_lines) + '\n')
-        return
-
-    # Fallback to classic nltvals.def.
-    if target is not None:
-        print(f'#ifdef NL_TARGET_{target}', file=output)
-    print(f'#ifdef {srctype}_defs', file=output)
-
-    print('\n'.join(f'/* from {x} */' for x in headers), file=output)
-
-    if target is None:
-        print(f'/* begin {srctype} target macros */', file=output)
-    else:
-        print(f'/* begin {target} {srctype} target macros */', file=output)
-
-    for sym, val in sorted(syms.items()):
-        print(f' {{ "{sym}", {val} }},', file=output)
-
-    print(f'#undef {srctype}_defs', file=output)
-    if target is None:
-        print(f'/* end {srctype} target macros */', file=output)
-    else:
-        print(f'/* end {target} {srctype} target macros */', file=output)
-        print('#endif', file=output)
-    print('#endif', file=output)
+    assert target_map.exists(), f'{target_map}: Missing skeleton'
+    old_lines = target_map.read_text().splitlines()
+    start_i = end_i = None
+    for i, line in enumerate(old_lines):
+        if START_MARKER in line:
+            start_i = i
+        if END_MARKER in line:
+            end_i = i
+    assert start_i and end_i
+    new_lines = old_lines[0:start_i + 1]
+    new_lines.extend(
+        f'#ifdef {sym}\n'
+        f'  {{ "{sym}", {sym}, {val} }},\n'
+        f'#endif' for sym, val in sorted(syms.items()))
+    new_lines.extend(old_lines[end_i:])
+    target_map.write_text('\n'.join(new_lines) + '\n')
 
 
-def gen_common(output_dir: Path, output: TextIO, newlib: Path, cpp: str):
+def gen_common(output_dir: Path, newlib: Path, cpp: str):
     """Generate the common C library constants.
 
     No arch should override these.
     """
-    gentvals(output_dir, output, cpp, 'errno', newlib / 'newlib/libc/include',
+    gentvals(output_dir, cpp, 'errno', newlib / 'newlib/libc/include',
              ('errno.h', 'sys/errno.h'), 'E[A-Z0-9]*')
 
-    gentvals(output_dir, output, cpp, 'signal', newlib / 'newlib/libc/include',
+    gentvals(output_dir, cpp, 'signal', newlib / 'newlib/libc/include',
              ('signal.h', 'sys/signal.h'), r'SIG[A-Z0-9]*', filter=r'SIGSTKSZ')
 
-    gentvals(output_dir, output, cpp, 'open', newlib / 'newlib/libc/include',
+    gentvals(output_dir, cpp, 'open', newlib / 'newlib/libc/include',
              ('fcntl.h', 'sys/fcntl.h', 'sys/_default_fcntl.h'), r'O_[A-Z0-9]*')
 
 
@@ -248,16 +223,15 @@ def gen_target_syscall(output_dir: Path, newlib: Path, cpp: str):
     target_map_h.write_text('\n'.join(new_lines_h) + '\n')
 
 
-def gen_targets(output_dir: Path, output: TextIO, newlib: Path, cpp: str):
+def gen_targets(output_dir: Path, newlib: Path, cpp: str):
     """Generate the target-specific lists."""
     gen_target_syscall(output_dir, newlib, cpp)
 
 
-def gen(output_dir: Path, output: TextIO, newlib: Path, cpp: str):
+def gen(output_dir: Path, newlib: Path, cpp: str):
     """Generate all the things!"""
-    print(FILE_HEADER, file=output)
-    gen_common(output_dir, output, newlib, cpp)
-    gen_targets(output_dir, output, newlib, cpp)
+    gen_common(output_dir, newlib, cpp)
+    gen_targets(output_dir, newlib, cpp)
 
 
 def get_parser() -> argparse.ArgumentParser:
@@ -315,9 +289,7 @@ def main(argv: List[str]) -> int:
     """The main entry point for scripts."""
     opts = parse_args(argv)
 
-    output = (opts.output / 'nltvals.def').open('w', encoding='utf-8')
-
-    gen(opts.output, output, opts.newlib, opts.cpp)
+    gen(opts.output, opts.newlib, opts.cpp)
     return 0
 
 
diff --git a/sim/common/gentmap.c b/sim/common/gentmap.c
deleted file mode 100644
index 4a55c2966943..000000000000
--- a/sim/common/gentmap.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/* Generate targ-vals.h and targ-map.c.  */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-struct tdefs {
-  char *symbol;
-  int value;
-};
-
-static struct tdefs sys_tdefs[] = {
-#define sys_defs
-#include "nltvals.def"
-#undef sys_defs
-  { 0, 0 }
-};
-
-static void
-gen_targ_vals_h (void)
-{
-  struct tdefs *t;
-
-  printf ("/* Target header values needed by the simulator and gdb.  */\n");
-  printf ("/* This file is machine generated by gentmap.c.  */\n\n");
-
-  printf ("#ifndef TARG_VALS_H\n");
-  printf ("#define TARG_VALS_H\n\n");
-
-  printf ("/* syscall values */\n");
-  for (t = &sys_tdefs[0]; t->symbol; ++t)
-    printf ("#define TARGET_%s %d\n", t->symbol, t->value);
-  printf ("\n");
-
-  printf ("#endif /* TARG_VALS_H */\n");
-}
-
-static void
-gen_targ_map_c (void)
-{
-  struct tdefs *t;
-
-  printf ("/* Target value mapping utilities needed by the simulator and gdb.  */\n");
-  printf ("/* This file is machine generated by gentmap.c.  */\n\n");
-
-  printf ("#include \"defs.h\"\n");
-  printf ("#include \"ansidecl.h\"\n");
-  printf ("#include \"sim/callback.h\"\n");
-  printf ("#include \"targ-vals.h\"\n");
-  printf ("\n");
-
-  printf ("/* syscall mapping table */\n");
-  printf ("CB_TARGET_DEFS_MAP cb_init_syscall_map[] = {\n");
-  for (t = &sys_tdefs[0]; t->symbol; ++t)
-    {
-      printf ("#ifdef CB_%s\n", t->symbol);
-      /* Skip the "SYS_" prefix for the name.  */
-      printf ("  { \"%s\", CB_%s, TARGET_%s },\n", t->symbol + 4, t->symbol, t->symbol);
-      printf ("#endif\n");
-    }
-  printf ("  { 0, -1, -1 }\n");
-  printf ("};\n\n");
-}
-
-int
-main (int argc, char *argv[])
-{
-  if (argc != 2)
-    abort ();
-
-  if (strcmp (argv[1], "-h") == 0)
-    gen_targ_vals_h ();
-  else if (strcmp (argv[1], "-c") == 0)
-    gen_targ_map_c ();
-  else
-    abort ();
-
-  exit (0);
-}
diff --git a/sim/common/nltvals.def b/sim/common/nltvals.def
deleted file mode 100644
index 2425b70e490a..000000000000
--- a/sim/common/nltvals.def
+++ /dev/null
@@ -1,248 +0,0 @@
-/* Newlib/libgloss macro values needed by remote target support.  */
-/* This file is machine generated by gennltvals.py.  */
-#ifdef NL_TARGET_cr16
-#ifdef sys_defs
-/* from syscall.h */
-/* begin cr16 sys target macros */
- { "SYS_ARG", 24 },
- { "SYS_chdir", 12 },
- { "SYS_chmod", 15 },
- { "SYS_chown", 16 },
- { "SYS_close", 0x402 },
- { "SYS_create", 8 },
- { "SYS_execv", 11 },
- { "SYS_execve", 59 },
- { "SYS_exit", 0x410 },
- { "SYS_fork", 2 },
- { "SYS_fstat", 22 },
- { "SYS_getpid", 20 },
- { "SYS_isatty", 21 },
- { "SYS_kill", 60 },
- { "SYS_link", 9 },
- { "SYS_lseek", 0x405 },
- { "SYS_mknod", 14 },
- { "SYS_open", 0x401 },
- { "SYS_pipe", 42 },
- { "SYS_read", 0x403 },
- { "SYS_rename", 0x406 },
- { "SYS_stat", 38 },
- { "SYS_time", 0x300 },
- { "SYS_unlink", 0x407 },
- { "SYS_utime", 201 },
- { "SYS_wait", 202 },
- { "SYS_wait4", 7 },
- { "SYS_write", 0x404 },
-#undef sys_defs
-/* end cr16 sys target macros */
-#endif
-#endif
-#ifdef NL_TARGET_d10v
-#ifdef sys_defs
-/* from syscall.h */
-/* begin d10v sys target macros */
- { "SYS_ARG", 24 },
- { "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_getpid", 20 },
- { "SYS_isatty", 21 },
- { "SYS_kill", 60 },
- { "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_unlink", 10 },
- { "SYS_utime", 201 },
- { "SYS_wait", 202 },
- { "SYS_wait4", 7 },
- { "SYS_write", 4 },
-#undef sys_defs
-/* end d10v sys target macros */
-#endif
-#endif
-#ifdef NL_TARGET_mcore
-#ifdef sys_defs
-/* from syscall.h */
-/* begin mcore sys target macros */
- { "SYS_access", 33 },
- { "SYS_close", 6 },
- { "SYS_creat", 8 },
- { "SYS_link", 9 },
- { "SYS_lseek", 19 },
- { "SYS_open", 5 },
- { "SYS_read", 3 },
- { "SYS_time", 13 },
- { "SYS_times", 43 },
- { "SYS_unlink", 10 },
- { "SYS_write", 4 },
-#undef sys_defs
-/* end mcore sys target macros */
-#endif
-#endif
-#ifdef NL_TARGET_riscv
-#ifdef sys_defs
-/* from syscall.h */
-/* begin riscv sys target macros */
- { "SYS_access", 1033 },
- { "SYS_brk", 214 },
- { "SYS_chdir", 49 },
- { "SYS_clock_gettime64", 403 },
- { "SYS_close", 57 },
- { "SYS_dup", 23 },
- { "SYS_exit", 93 },
- { "SYS_exit_group", 94 },
- { "SYS_faccessat", 48 },
- { "SYS_fcntl", 25 },
- { "SYS_fstat", 80 },
- { "SYS_fstatat", 79 },
- { "SYS_getcwd", 17 },
- { "SYS_getdents", 61 },
- { "SYS_getegid", 177 },
- { "SYS_geteuid", 175 },
- { "SYS_getgid", 176 },
- { "SYS_getmainvars", 2011 },
- { "SYS_getpid", 172 },
- { "SYS_gettimeofday", 169 },
- { "SYS_getuid", 174 },
- { "SYS_kill", 129 },
- { "SYS_link", 1025 },
- { "SYS_lseek", 62 },
- { "SYS_lstat", 1039 },
- { "SYS_mkdir", 1030 },
- { "SYS_mmap", 222 },
- { "SYS_mremap", 216 },
- { "SYS_munmap", 215 },
- { "SYS_open", 1024 },
- { "SYS_openat", 56 },
- { "SYS_pread", 67 },
- { "SYS_pwrite", 68 },
- { "SYS_read", 63 },
- { "SYS_rt_sigaction", 134 },
- { "SYS_stat", 1038 },
- { "SYS_time", 1062 },
- { "SYS_times", 153 },
- { "SYS_uname", 160 },
- { "SYS_unlink", 1026 },
- { "SYS_write", 64 },
- { "SYS_writev", 66 },
-#undef sys_defs
-/* end riscv 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 },
-#undef sys_defs
-/* end sh sys target macros */
-#endif
-#endif
-#ifdef NL_TARGET_v850
-#ifdef sys_defs
-/* from syscall.h */
-/* begin v850 sys target macros */
- { "SYS_ARG", 24 },
- { "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_getpid", 20 },
- { "SYS_gettimeofday", 116 },
- { "SYS_isatty", 21 },
- { "SYS_link", 9 },
- { "SYS_lseek", 19 },
- { "SYS_mknod", 14 },
- { "SYS_open", 5 },
- { "SYS_pipe", 42 },
- { "SYS_read", 3 },
- { "SYS_rename", 134 },
- { "SYS_stat", 38 },
- { "SYS_time", 23 },
- { "SYS_times", 43 },
- { "SYS_unlink", 10 },
- { "SYS_utime", 201 },
- { "SYS_wait", 202 },
- { "SYS_wait4", 7 },
- { "SYS_write", 4 },
-#undef sys_defs
-/* end v850 sys target macros */
-#endif
-#endif
-#ifdef sys_defs
-/* from syscall.h */
-/* begin sys target macros */
- { "SYS_argc", 22 },
- { "SYS_argn", 24 },
- { "SYS_argnlen", 23 },
- { "SYS_argv", 13 },
- { "SYS_argvlen", 12 },
- { "SYS_chdir", 14 },
- { "SYS_chmod", 16 },
- { "SYS_close", 3 },
- { "SYS_exit", 1 },
- { "SYS_fstat", 10 },
- { "SYS_getpid", 8 },
- { "SYS_gettimeofday", 19 },
- { "SYS_kill", 9 },
- { "SYS_link", 21 },
- { "SYS_lseek", 6 },
- { "SYS_open", 2 },
- { "SYS_read", 4 },
- { "SYS_reconfig", 25 },
- { "SYS_stat", 15 },
- { "SYS_time", 18 },
- { "SYS_times", 20 },
- { "SYS_unlink", 7 },
- { "SYS_utime", 17 },
- { "SYS_write", 5 },
-#undef sys_defs
-/* end sys target macros */
-#endif
diff --git a/sim/mips/Makefile.in b/sim/mips/Makefile.in
index 8a9241dd680e..5c669279ae63 100644
--- a/sim/mips/Makefile.in
+++ b/sim/mips/Makefile.in
@@ -454,7 +454,7 @@ BUILT_SRC_FROM_MULTI = @sim_multi_src@
 SIM_MULTI_IGEN_CONFIGS = @sim_multi_igen_configs@
 
 $(BUILT_SRC_FROM_MULTI): tmp-multi
-tmp-multi: tmp-mach-multi tmp-itable-multi tmp-run-multi targ-vals.h
+tmp-multi: tmp-mach-multi tmp-itable-multi tmp-run-multi
 tmp-mach-multi: $(IGEN_INSN) $(IGEN_DC) $(IGEN) $(IGEN_INCLUDE)
 	for t in $(SIM_MULTI_IGEN_CONFIGS); do \
 	  p=`echo $${t} | sed -e 's/:.*//'` ; \
-- 
2.33.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-11-28  8:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 4/9] sim: sh: " 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

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).