sim: nltvafs: unify common syscall tables

Message ID 20210425232337.9197-1-vapier@gentoo.org
State New
Headers show
Series
  • sim: nltvafs: unify common syscall tables
Related show

Commit Message

Mike Frysinger via Gdb-patches April 25, 2021, 11:23 p.m.
Since libgloss provides a default syscall table for arches, use that
to provide the default syscall table for ports.  Only the exceptions
need to be enumerated now with the common logic as the default.
---
 sim/README-HACKING       |   7 +-
 sim/bfin/Makefile.in     |   3 -
 sim/common/gennltvals.py |  49 ++--
 sim/common/nltvals.def   | 474 ++++-----------------------------------
 sim/cris/Makefile.in     |   3 -
 sim/frv/Makefile.in      |   3 -
 sim/iq2000/Makefile.in   |   3 -
 sim/lm32/Makefile.in     |   3 -
 sim/m32c/Makefile.in     |   3 -
 sim/m32r/Makefile.in     |   3 -
 sim/mn10300/Makefile.in  |   3 -
 sim/moxie/Makefile.in    |   3 -
 sim/msp430/Makefile.in   |   3 -
 sim/pru/Makefile.in      |   2 -
 sim/rx/Makefile.in       |   3 -
 15 files changed, 57 insertions(+), 508 deletions(-)

-- 
2.30.2

Patch

diff --git a/sim/README-HACKING b/sim/README-HACKING
index 78580588bf2b..bd0054fd22e5 100644
--- a/sim/README-HACKING
+++ b/sim/README-HACKING
@@ -180,7 +180,7 @@  got one to hand):
 	$  cd /tmp/$$
 	$  cvs checkout sim-no-testsuite libgloss-no-testsuite newlib-no-testsuite
 
-Configure things for an arbitrary simulator target (I've d10v for
+Configure things for an arbitrary simulator target (d10v is used here for
 convenience):
 
 	$  mkdir /tmp/$$/build
@@ -192,9 +192,10 @@  In the sim/ directory rebuild the headers:
 	$  cd sim/
 	$  make nltvals
 
-To add a new target:
+If the target uses the common syscall table (libgloss/syscall.h), then you're
+all set!  If the target has a custom syscall table, you need to declare it:
 
-	devo/sim/common/gennltvals.sh
+	devo/sim/common/gennltvals.py
 
 		Add your new processor target (you'll need to grub
 		around to find where your syscall.h lives).
diff --git a/sim/bfin/Makefile.in b/sim/bfin/Makefile.in
index a5c16764682b..c53acd11030a 100644
--- a/sim/bfin/Makefile.in
+++ b/sim/bfin/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_bfin
-
 ## COMMON_PRE_CONFIG_FRAG
 
 SIM_OBJS = \
diff --git a/sim/common/gennltvals.py b/sim/common/gennltvals.py
index cf23c3926994..b3e558d580a9 100755
--- a/sim/common/gennltvals.py
+++ b/sim/common/gennltvals.py
@@ -37,12 +37,13 @@  from typing import Iterable, List, TextIO
 
 PROG = Path(__file__).name
 
-# Unfortunately, each newlib/libgloss port has seen fit to define their own
+# Unfortunately, many newlib/libgloss ports have seen fit to define their own
 # syscall.h file.  This means that system call numbers can vary for each port.
 # Support for all this crud is kept here, rather than trying to get too fancy.
 # If you want to try to improve this, please do, but don't break anything.
-# Note that there is a standard syscall.h file (libgloss/syscall.h) now which
-# hopefully more targets can use.
+#
+# If a target isn't listed here, it gets the standard syscall.h file (see
+# libgloss/syscall.h) which hopefully new targets will use.
 #
 # NB: New ports should use libgloss, not newlib.
 TARGET_DIRS = {
@@ -54,32 +55,7 @@  TARGET_DIRS = {
     'sh': 'newlib/libc/sys/sh/sys',
     'v850': 'libgloss/v850/sys',
 }
-TARGETS = {
-    'bfin',
-    'cr16',
-    'd10v',
-    'fr30',
-    'frv',
-    'i960',
-    'iq2000',
-    'lm32',
-    'm32c',
-    'm32r',
-    'mcore',
-    'mn10200',
-    'mn10300',
-    'moxie',
-    'msp430',
-    'pru',
-    'riscv',
-    'rx',
-    'sh',
-    'sparc',
-    'v850',
-}
 
-# Make sure TARGET_DIRS doesn't gain any typos.
-assert not set(TARGET_DIRS) - TARGETS
 
 # The header for the generated def file.
 FILE_HEADER = f"""\
@@ -103,11 +79,9 @@  def gentvals(output: TextIO, cpp: str, srctype: str, srcdir: Path,
         fullpath = srcdir / header
         assert fullpath.exists(), f'{fullpath} does not exist'
 
-    if target is None:
-        print(f'#ifdef {srctype}_defs', file=output)
-    else:
+    if target is not None:
         print(f'#ifdef NL_TARGET_{target}', file=output)
-        print(f'#ifdef {srctype}_defs', file=output)
+    print(f'#ifdef {srctype}_defs', file=output)
 
     print('\n'.join(f'/* from {x} */' for x in headers), file=output)
 
@@ -137,13 +111,13 @@  def gentvals(output: TextIO, cpp: str, srctype: str, srcdir: Path,
         if line.startswith('DEFVAL '):
             print(line[6:].rstrip(), file=output)
 
+    print(f'#undef {srctype}_defs', file=output)
     if target is None:
         print(f'/* end {srctype} target macros */', file=output)
-        print('#endif', file=output)
     else:
         print(f'/* end {target} {srctype} target macros */', file=output)
         print('#endif', file=output)
-        print('#endif', file=output)
+    print('#endif', file=output)
 
 
 def gen_common(output: TextIO, newlib: Path, cpp: str):
@@ -163,11 +137,14 @@  def gen_common(output: TextIO, newlib: Path, cpp: str):
 
 def gen_targets(output: TextIO, newlib: Path, cpp: str):
     """Generate the target-specific lists."""
-    for target in sorted(TARGETS):
-        subdir = TARGET_DIRS.get(target, 'libgloss')
+    for target, subdir in sorted(TARGET_DIRS.items()):
         gentvals(output, cpp, 'sys', newlib / subdir, ('syscall.h',),
                  r'SYS_[_a-zA-Z0-9]*', target=target)
 
+    # Then output the common syscall targets.
+    gentvals(output, cpp, 'sys', newlib / 'libgloss', ('syscall.h',),
+             r'SYS_[_a-zA-Z0-9]*')
+
 
 def gen(output: TextIO, newlib: Path, cpp: str):
     """Generate all the things!"""
diff --git a/sim/common/nltvals.def b/sim/common/nltvals.def
index 27f1b0d43b26..8ae88397249c 100644
--- a/sim/common/nltvals.def
+++ b/sim/common/nltvals.def
@@ -89,6 +89,7 @@ 
  { "ETXTBSY", 26 },
  { "EWOULDBLOCK", 11 },
  { "EXDEV", 18 },
+#undef errno_defs
 /* end errno target macros */
 #endif
 #ifdef signal_defs
@@ -130,6 +131,7 @@ 
  { "SIGWINCH", 28 },
  { "SIGXCPU", 24 },
  { "SIGXFSZ", 25 },
+#undef signal_defs
 /* end signal target macros */
 #endif
 #ifdef open_defs
@@ -154,39 +156,9 @@ 
  { "O_SYNC", 0x2000 },
  { "O_TRUNC", 0x0400 },
  { "O_WRONLY", 1 },
+#undef open_defs
 /* end open target macros */
 #endif
-#ifdef NL_TARGET_bfin
-#ifdef sys_defs
-/* from syscall.h */
-/* begin bfin 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 },
-/* end bfin sys target macros */
-#endif
-#endif
 #ifdef NL_TARGET_cr16
 #ifdef sys_defs
 /* from syscall.h */
@@ -219,6 +191,7 @@ 
  { "SYS_wait", 202 },
  { "SYS_wait4", 7 },
  { "SYS_write", 0x404 },
+#undef sys_defs
 /* end cr16 sys target macros */
 #endif
 #endif
@@ -253,71 +226,10 @@ 
  { "SYS_wait", 202 },
  { "SYS_wait4", 7 },
  { "SYS_write", 4 },
+#undef sys_defs
 /* end d10v sys target macros */
 #endif
 #endif
-#ifdef NL_TARGET_fr30
-#ifdef sys_defs
-/* from syscall.h */
-/* begin fr30 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 },
-/* end fr30 sys target macros */
-#endif
-#endif
-#ifdef NL_TARGET_frv
-#ifdef sys_defs
-/* from syscall.h */
-/* begin frv 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 },
-/* end frv sys target macros */
-#endif
-#endif
 #ifdef NL_TARGET_i960
 #ifdef sys_defs
 /* from syscall.h */
@@ -339,133 +251,10 @@ 
  { "SYS_unlink", 7 },
  { "SYS_utime", 17 },
  { "SYS_write", 232 },
+#undef sys_defs
 /* end i960 sys target macros */
 #endif
 #endif
-#ifdef NL_TARGET_iq2000
-#ifdef sys_defs
-/* from syscall.h */
-/* begin iq2000 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 },
-/* end iq2000 sys target macros */
-#endif
-#endif
-#ifdef NL_TARGET_lm32
-#ifdef sys_defs
-/* from syscall.h */
-/* begin lm32 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 },
-/* end lm32 sys target macros */
-#endif
-#endif
-#ifdef NL_TARGET_m32c
-#ifdef sys_defs
-/* from syscall.h */
-/* begin m32c 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 },
-/* end m32c sys target macros */
-#endif
-#endif
-#ifdef NL_TARGET_m32r
-#ifdef sys_defs
-/* from syscall.h */
-/* begin m32r 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 },
-/* end m32r sys target macros */
-#endif
-#endif
 #ifdef NL_TARGET_mcore
 #ifdef sys_defs
 /* from syscall.h */
@@ -481,164 +270,10 @@ 
  { "SYS_times", 43 },
  { "SYS_unlink", 10 },
  { "SYS_write", 4 },
+#undef sys_defs
 /* end mcore sys target macros */
 #endif
 #endif
-#ifdef NL_TARGET_mn10200
-#ifdef sys_defs
-/* from syscall.h */
-/* begin mn10200 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 },
-/* end mn10200 sys target macros */
-#endif
-#endif
-#ifdef NL_TARGET_mn10300
-#ifdef sys_defs
-/* from syscall.h */
-/* begin mn10300 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 },
-/* end mn10300 sys target macros */
-#endif
-#endif
-#ifdef NL_TARGET_moxie
-#ifdef sys_defs
-/* from syscall.h */
-/* begin moxie 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 },
-/* end moxie sys target macros */
-#endif
-#endif
-#ifdef NL_TARGET_msp430
-#ifdef sys_defs
-/* from syscall.h */
-/* begin msp430 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 },
-/* end msp430 sys target macros */
-#endif
-#endif
-#ifdef NL_TARGET_pru
-#ifdef sys_defs
-/* from syscall.h */
-/* begin pru 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 },
-/* end pru sys target macros */
-#endif
-#endif
 #ifdef NL_TARGET_riscv
 #ifdef sys_defs
 /* from syscall.h */
@@ -685,40 +320,10 @@ 
  { "SYS_unlink", 1026 },
  { "SYS_write", 64 },
  { "SYS_writev", 66 },
+#undef sys_defs
 /* end riscv sys target macros */
 #endif
 #endif
-#ifdef NL_TARGET_rx
-#ifdef sys_defs
-/* from syscall.h */
-/* begin rx 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 },
-/* end rx sys target macros */
-#endif
-#endif
 #ifdef NL_TARGET_sh
 #ifdef sys_defs
 /* from syscall.h */
@@ -754,40 +359,10 @@ 
  { "SYS_wait", 202 },
  { "SYS_wait4", 7 },
  { "SYS_write", 4 },
+#undef sys_defs
 /* end sh sys target macros */
 #endif
 #endif
-#ifdef NL_TARGET_sparc
-#ifdef sys_defs
-/* from syscall.h */
-/* begin sparc 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 },
-/* end sparc sys target macros */
-#endif
-#endif
 #ifdef NL_TARGET_v850
 #ifdef sys_defs
 /* from syscall.h */
@@ -821,6 +396,37 @@ 
  { "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/cris/Makefile.in b/sim/cris/Makefile.in
index 87c1efe46821..67588ce8b1d1 100644
--- a/sim/cris/Makefile.in
+++ b/sim/cris/Makefile.in
@@ -40,9 +40,6 @@  SIM_EXTRA_DEPS = \
 
 SIM_EXTRA_CLEAN = cris-clean
 
-# This selects the cris newlib/libgloss syscall definitions.
-NL_TARGET = -DNL_TARGET_cris
-
 ## COMMON_POST_CONFIG_FRAG
 
 arch = cris
diff --git a/sim/frv/Makefile.in b/sim/frv/Makefile.in
index 875996140204..7d1eaf51e022 100644
--- a/sim/frv/Makefile.in
+++ b/sim/frv/Makefile.in
@@ -40,9 +40,6 @@  SIM_EXTRA_CFLAGS = @sim_trapdump@
 
 SIM_EXTRA_CLEAN = frv-clean
 
-# This selects the frv newlib/libgloss syscall definitions.
-NL_TARGET = -DNL_TARGET_frv
-
 ## COMMON_POST_CONFIG_FRAG
 
 arch = frv
diff --git a/sim/iq2000/Makefile.in b/sim/iq2000/Makefile.in
index 6047033b305b..dfa0e67a767d 100644
--- a/sim/iq2000/Makefile.in
+++ b/sim/iq2000/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_iq2000
-
 ## COMMON_PRE_CONFIG_FRAG
 
 IQ2000_OBJS = iq2000.o cpu.o decode.o sem.o model.o mloop.o
diff --git a/sim/lm32/Makefile.in b/sim/lm32/Makefile.in
index 51e6269d27c0..31c39400df88 100644
--- a/sim/lm32/Makefile.in
+++ b/sim/lm32/Makefile.in
@@ -22,9 +22,6 @@  SIM_EXTRA_DEPS = $(CGEN_INCLUDE_DEPS) $(srcdir)/../../opcodes/lm32-desc.h \
 
 SIM_EXTRA_CLEAN = lm32-clean
 
-# This selects the lm32 newlib/libgloss syscall definitions.
-NL_TARGET = -DNL_TARGET_lm32
-
 ## COMMON_POST_CONFIG_FRAG
 
 arch = lm32 
diff --git a/sim/m32c/Makefile.in b/sim/m32c/Makefile.in
index 7e27eb57da0a..05aa75309fa1 100644
--- a/sim/m32c/Makefile.in
+++ b/sim/m32c/Makefile.in
@@ -18,9 +18,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_m32c
-
 ## COMMON_PRE_CONFIG_FRAG
 
 SIM_EXTRA_CFLAGS = -Wall -DTIMER_A
diff --git a/sim/m32r/Makefile.in b/sim/m32r/Makefile.in
index fe470f6fc26f..2bb246d2524c 100644
--- a/sim/m32r/Makefile.in
+++ b/sim/m32r/Makefile.in
@@ -44,9 +44,6 @@  SIM_EXTRA_CFLAGS = @sim_extra_cflags@
 
 SIM_EXTRA_CLEAN = m32r-clean
 
-# This selects the m32r newlib/libgloss syscall definitions.
-NL_TARGET = -DNL_TARGET_m32r
-
 ## COMMON_POST_CONFIG_FRAG
 
 arch = m32r
diff --git a/sim/mn10300/Makefile.in b/sim/mn10300/Makefile.in
index 9852f663ecb4..39faa30efc2b 100644
--- a/sim/mn10300/Makefile.in
+++ b/sim/mn10300/Makefile.in
@@ -29,9 +29,6 @@  SIM_EXTRA_CLEAN = clean-igen
 # Extra dependencies for "sim-main.h"
 SIM_EXTRA_DEPS = mn10300_sim.h itable.h idecode.h
 
-# Select mn10300 support in nltvals.def.
-NL_TARGET = -DNL_TARGET_mn10300
-
 # List of extra flags to always pass to $(CC).
 SIM_EXTRA_CFLAGS = -DPOLL_QUIT_INTERVAL=0x20
 
diff --git a/sim/moxie/Makefile.in b/sim/moxie/Makefile.in
index 3d9618846cc3..bd58074491fc 100644
--- a/sim/moxie/Makefile.in
+++ b/sim/moxie/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_moxie
-
 ## COMMON_PRE_CONFIG_FRAG
 
 DTC = @DTC@
diff --git a/sim/msp430/Makefile.in b/sim/msp430/Makefile.in
index 113f28d3c903..b32a38b07e42 100644
--- a/sim/msp430/Makefile.in
+++ b/sim/msp430/Makefile.in
@@ -41,9 +41,6 @@  SIM_EXTRA_INSTALL =
 # Dependency of `clean' to clean any extra files.
 SIM_EXTRA_CLEAN =
 
-# This selects the MSP430 newlib/libgloss syscall definitions.
-NL_TARGET = -DNL_TARGET_msp430
-
 ## COMMON_POST_CONFIG_FRAG
 
 # Rules need to build $(SIM_OBJS), plus whatever else the target wants.
diff --git a/sim/pru/Makefile.in b/sim/pru/Makefile.in
index 7dd79b4bba62..7d4ff7a4dcae 100644
--- a/sim/pru/Makefile.in
+++ b/sim/pru/Makefile.in
@@ -24,6 +24,4 @@  SIM_OBJS = \
 	interp.o \
 	sim-resume.o
 
-NL_TARGET = -DNL_TARGET_pru
-
 ## COMMON_POST_CONFIG_FRAG
diff --git a/sim/rx/Makefile.in b/sim/rx/Makefile.in
index 9e83e3aad856..4008aac26194 100644
--- a/sim/rx/Makefile.in
+++ b/sim/rx/Makefile.in
@@ -18,9 +18,6 @@ 
 ### You should have received a copy of the GNU General Public License
 ### along with the GNU simulators; if not, see <http://www.gnu.org/licenses/>.
 
-# This selects the newlib/libgloss syscall definitions.
-NL_TARGET = -DNL_TARGET_rx
-
 ## COMMON_PRE_CONFIG_FRAG
 
 SIM_EXTRA_CFLAGS = -Wall