[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC v2 4/6] common-user: Adjust system call return on FreeBSD
From: |
Richard Henderson |
Subject: |
Re: [RFC v2 4/6] common-user: Adjust system call return on FreeBSD |
Date: |
Wed, 10 Nov 2021 17:59:29 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 |
On 11/10/21 5:31 PM, Warner Losh wrote:
All the *-users generally use the Linux style of negative return codes
for errno. FreeBSD returns errno, not -errno. Add ifdefs for FreeBSD to
make the adjustment on the 4 hosts that we have support for.
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
common-user/host/aarch64/safe-syscall.inc.S | 5 +++++
common-user/host/arm/safe-syscall.inc.S | 5 +++++
common-user/host/i386/safe-syscall.inc.S | 5 +++++
common-user/host/x86_64/safe-syscall.inc.S | 5 +++++
4 files changed, 20 insertions(+)
diff --git a/common-user/host/aarch64/safe-syscall.inc.S
b/common-user/host/aarch64/safe-syscall.inc.S
index bc1f5a9792..6584950ccf 100644
--- a/common-user/host/aarch64/safe-syscall.inc.S
+++ b/common-user/host/aarch64/safe-syscall.inc.S
@@ -64,6 +64,11 @@ safe_syscall_start:
svc 0x0
safe_syscall_end:
/* code path for having successfully executed the syscall */
+#ifdef __FreeBSD__
+ b.cc 2f /* Convert to Linux -ERRNO convention */
+ neg x0, x0
+2:
+#endif
I think it should be a little odd to mention Linux.
How about
/*
* FreeBSD kernel returns C bit set with positive errno.
* Encode this for use in bsd-user as -errno:
* x0 = !c ? x0 : -x0
*/
csneg x0, x0, x0, cc
+++ b/common-user/host/arm/safe-syscall.inc.S
@@ -78,6 +78,11 @@ safe_syscall_start:
swi 0
safe_syscall_end:
/* code path for having successfully executed the syscall */
+#ifdef __FreeBSD__
+ bcc 2f
+ neg r0, r0
negcs r0, r0
I just can't help myself. :-)
r~
- [RFC v2 0/6] linux-user: simplify safe signal handling, Warner Losh, 2021/11/10
- [RFC v2 1/6] linux-user: Add host_signal_set_pc to set pc in mcontext, Warner Losh, 2021/11/10
- [RFC v2 4/6] common-user: Adjust system call return on FreeBSD, Warner Losh, 2021/11/10
- Re: [RFC v2 4/6] common-user: Adjust system call return on FreeBSD,
Richard Henderson <=
- [RFC v2 3/6] linux-user/safe-syscall.inc.S: Move to common-user, Warner Losh, 2021/11/10
- [RFC v2 6/6] *-user: move safe-syscall.* to common-user, Warner Losh, 2021/11/10
- [RFC v2 2/6] linux-user/signal.c: Create a common rewind_if_in_safe_syscall, Warner Losh, 2021/11/10
- [RFC v2 5/6] common-user/host/mips: create, though mips hosts likely don't work reliably, Warner Losh, 2021/11/10