]> git.proxmox.com Git - mirror_qemu.git/commitdiff
bsd-user: Implement host_to_target_waitstatus conversion.
authorStacey Son <sson@FreeBSD.org>
Mon, 25 Sep 2023 18:24:06 +0000 (21:24 +0300)
committerWarner Losh <imp@bsdimp.com>
Tue, 3 Oct 2023 23:14:06 +0000 (17:14 -0600)
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>

bsd-user/bsd-proc.c

index aa386ff482000b45f3cb31fe0b69fe52a7bd7518..19f6efe1f78dc73c8ea8143ca693a289d7795520 100644 (file)
@@ -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;
+}
+