aboutsummaryrefslogtreecommitdiff
path: root/bsd-user
diff options
context:
space:
mode:
authorStacey Son <sson@FreeBSD.org>2023-09-25 21:24:06 +0300
committerWarner Losh <imp@bsdimp.com>2023-10-03 17:14:06 -0600
commit3f44e273ff530ae9885b64791779ced571233d1d (patch)
tree5985e1c67074eaa6e552bdac8a1305b1f3b5dbc8 /bsd-user
parent66c51d63d408fe4130d3fb63524d7a009e1e01a6 (diff)
downloadqemu-3f44e273ff530ae9885b64791779ced571233d1d.zip
qemu-3f44e273ff530ae9885b64791779ced571233d1d.tar.gz
qemu-3f44e273ff530ae9885b64791779ced571233d1d.tar.bz2
bsd-user: Implement host_to_target_waitstatus conversion.
Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Warner Losh <imp@bsdimp.com> Message-Id: <20230925182425.3163-10-kariem.taha2.7@gmail.com>
Diffstat (limited to 'bsd-user')
-rw-r--r--bsd-user/bsd-proc.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/bsd-user/bsd-proc.c b/bsd-user/bsd-proc.c
index aa386ff..19f6efe 100644
--- a/bsd-user/bsd-proc.c
+++ b/bsd-user/bsd-proc.c
@@ -102,3 +102,20 @@ abi_long host_to_target_wrusage(abi_ulong target_addr,
return 0;
}
+/*
+ * wait status conversion.
+ *
+ * Map host to target signal numbers for the wait family of syscalls.
+ * Assume all other status bits are the same.
+ */
+int host_to_target_waitstatus(int status)
+{
+ if (WIFSIGNALED(status)) {
+ return host_to_target_signal(WTERMSIG(status)) | (status & ~0x7f);
+ }
+ if (WIFSTOPPED(status)) {
+ return (host_to_target_signal(WSTOPSIG(status)) << 8) | (status & 0xff);
+ }
+ return status;
+}
+