From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id 480E33857C70 for ; Sun, 28 Nov 2021 08:44:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 480E33857C70 Received: by smtp.gentoo.org (Postfix, from userid 559) id CA319342F20; Sun, 28 Nov 2021 08:44:17 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH 6/9] sim: cr16: switch to new target-newlib-syscall Date: Sun, 28 Nov 2021 03:43:55 -0500 Message-Id: <20211128084358.29302-6-vapier@gentoo.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211128084358.29302-1-vapier@gentoo.org> References: <20211128084358.29302-1-vapier@gentoo.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Nov 2021 08:44:20 -0000 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 #endif -#ifdef TARGET_SYS_wait #include -#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 ("", 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 ("", 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 ("", 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 ("", 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 ("", 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 ("", 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 ("", 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 ("", 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 ("", 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 ("", 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 ("", 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 ("", 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 ("", 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 ("", 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 ("", 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 ("", 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 ("", 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 ("", 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 ("", 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 ("", 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 ("", 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 ("