From: Mike Frysinger Date: Mon, 19 Apr 2021 00:53:03 +0000 (-0400) Subject: sim: syscall: add getpid support X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7da5cf78fb1ba3e93cc5e79cf5084bd2b03f0fcf;p=binutils-gdb.git sim: syscall: add getpid support Hoist the Blackfin implementation up to the common one. --- diff --git a/sim/bfin/ChangeLog b/sim/bfin/ChangeLog index 2a48fe102a3..51d48b86c12 100644 --- a/sim/bfin/ChangeLog +++ b/sim/bfin/ChangeLog @@ -1,3 +1,7 @@ +2021-04-18 Mike Frysinger + + * interp.c (bfin_syscall): Delete CB_SYS_getpid handling. + 2021-04-12 Mike Frysinger * interp.c (sim_open): Delete 3rd arg to sim_cpu_alloc_all. diff --git a/sim/bfin/interp.c b/sim/bfin/interp.c index 747898ceff5..49388e74c54 100644 --- a/sim/bfin/interp.c +++ b/sim/bfin/interp.c @@ -457,10 +457,6 @@ bfin_syscall (SIM_CPU *cpu) sc.result = setgid (sc.arg1); goto sys_finish; - case CB_SYS_getpid: - tbuf += sprintf (tbuf, "getpid()"); - sc.result = getpid (); - goto sys_finish; case CB_SYS_kill: tbuf += sprintf (tbuf, "kill(%u, %i)", args[0], args[1]); /* Only let the app kill itself. */ diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index c8782d7c34b..b1af152930a 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,3 +1,7 @@ +2021-04-18 Mike Frysinger + + * syscall.c (cb_syscall): Implement CB_SYS_getpid. + 2021-04-15 John Baldwin * Make-common.in (CONFIG_CFLAGS): Remove SIM_EXTRA_CFLAGS. diff --git a/sim/common/syscall.c b/sim/common/syscall.c index fbe8021c8ef..f2883c493ac 100644 --- a/sim/common/syscall.c +++ b/sim/common/syscall.c @@ -578,6 +578,10 @@ cb_syscall (host_callback *cb, CB_SYSCALL *sc) } break; + case CB_SYS_getpid: + result = getpid (); + break; + case CB_SYS_time : { /* FIXME: May wish to change CB_SYS_time to something else. diff --git a/sim/testsuite/bfin/ChangeLog b/sim/testsuite/bfin/ChangeLog index 2abca7eee7c..ea617e3fdff 100644 --- a/sim/testsuite/bfin/ChangeLog +++ b/sim/testsuite/bfin/ChangeLog @@ -1,3 +1,7 @@ +2021-04-18 Mike Frysinger + + * getpid.c: New test. + 2021-04-08 Mike Frysinger * allinsn.exp (arch): Delete. diff --git a/sim/testsuite/bfin/getpid.c b/sim/testsuite/bfin/getpid.c new file mode 100644 index 00000000000..11d5c50868d --- /dev/null +++ b/sim/testsuite/bfin/getpid.c @@ -0,0 +1,18 @@ +/* Basic getpid tests. +# mach: bfin +# cc: -msim +*/ + +#include +#include + +int main(int argc, char *argv[]) +{ + pid_t pid = getpid(); + if (pid < 0) { + perror("getpid failed"); + return 1; + } + puts("pass"); + return 0; +}