Skip to content

Commit

Permalink
Tidy up comments in the x86 syscall code.
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfishcode committed Feb 17, 2022
1 parent b29eb41 commit 4b4204c
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/imp/linux_raw/arch/inline/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,10 @@ pub(in crate::imp) unsafe fn syscall5(
a4: ArgReg<'_, A4>,
) -> RetReg<R0> {
let r0;
// As in syscall 4, use xchg to handle a3. a4 should go in edi, and
// we can use that register as an operand.
// As in `syscall4`, use xchg to handle a3. a4 should go in edi, and we can
// use that register as an operand. Unlike in `indirect_syscall5`, we don't
// have a `callee` operand taking up a register, so we have enough
// registers and don't need to use a slice.
asm!(
".ifnes \"{a3}\",\"esi\"",
"xchg esi, {a3}",
Expand Down Expand Up @@ -448,6 +450,7 @@ pub(in crate::imp) unsafe fn syscall5_readonly(
a4: ArgReg<'_, A4>,
) -> RetReg<R0> {
let r0;
// See the comments in `syscall5`.
asm!(
".ifnes \"{a3}\",\"esi\"",
"xchg esi, {a3}",
Expand Down Expand Up @@ -479,14 +482,7 @@ pub(in crate::imp) unsafe fn syscall6(
a5: ArgReg<'_, A5>,
) -> RetReg<R0> {
let r0;
// Oof. a3 should go in esi, and a5 should go in ebp, and `asm!` won't
// let us use either of those registers as operands. And we can't request
// stack slots. And there are no other registers free. Use eax as a
// temporary pointer to a slice, since it gets clobbered as the return
// value anyway.
//
// This is another reason that syscalls should be compiler intrinsics
// rather than inline asm.
// See the comments in `indirect_syscall6`.
asm!(
"push ebp",
"push esi",
Expand Down Expand Up @@ -518,6 +514,7 @@ pub(in crate::imp) unsafe fn syscall6_readonly(
a5: ArgReg<'_, A5>,
) -> RetReg<R0> {
let r0;
// See the comments in `indirect_syscall6`.
asm!(
"push ebp",
"push esi",
Expand Down

0 comments on commit 4b4204c

Please sign in to comment.