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>
master
Stacey Son 2023-09-25 21:24:06 +03:00 committed by Warner Losh
parent 66c51d63d4
commit 3f44e273ff
1 changed files with 17 additions and 0 deletions

View 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;
}