aboutsummaryrefslogtreecommitdiff
path: root/common-user/host/i386/safe-syscall.inc.S
diff options
context:
space:
mode:
Diffstat (limited to 'common-user/host/i386/safe-syscall.inc.S')
-rw-r--r--common-user/host/i386/safe-syscall.inc.S11
1 files changed, 11 insertions, 0 deletions
diff --git a/common-user/host/i386/safe-syscall.inc.S b/common-user/host/i386/safe-syscall.inc.S
index aced8c5141..baf5400a29 100644
--- a/common-user/host/i386/safe-syscall.inc.S
+++ b/common-user/host/i386/safe-syscall.inc.S
@@ -71,9 +71,18 @@ safe_syscall_start:
mov 8+16(%esp), %eax /* syscall number */
int $0x80
safe_syscall_end:
+
/* code path for having successfully executed the syscall */
+#if defined(__linux__)
+ /* Linux kernel returns (small) negative errno. */
cmp $-4095, %eax
jae 0f
+#elif defined(__FreeBSD__)
+ /* FreeBSD kernel returns positive errno and C bit set. */
+ jc 1f
+#else
+#error "unsupported os"
+#endif
pop %ebx
.cfi_remember_state
.cfi_adjust_cfa_offset -4
@@ -90,8 +99,10 @@ safe_syscall_end:
ret
.cfi_restore_state
+#if defined(__linux__)
0: neg %eax
jmp 1f
+#endif
/* code path when we didn't execute the syscall */
2: mov $QEMU_ERESTARTSYS, %eax