Skip to content

Commit 4b4204c

Browse files
committed
Tidy up comments in the x86 syscall code.
1 parent b29eb41 commit 4b4204c

File tree

1 file changed

+7
-10
lines changed
  • src/imp/linux_raw/arch/inline

1 file changed

+7
-10
lines changed

src/imp/linux_raw/arch/inline/x86.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,10 @@ pub(in crate::imp) unsafe fn syscall5(
416416
a4: ArgReg<'_, A4>,
417417
) -> RetReg<R0> {
418418
let r0;
419-
// As in syscall 4, use xchg to handle a3. a4 should go in edi, and
420-
// we can use that register as an operand.
419+
// As in `syscall4`, use xchg to handle a3. a4 should go in edi, and we can
420+
// use that register as an operand. Unlike in `indirect_syscall5`, we don't
421+
// have a `callee` operand taking up a register, so we have enough
422+
// registers and don't need to use a slice.
421423
asm!(
422424
".ifnes \"{a3}\",\"esi\"",
423425
"xchg esi, {a3}",
@@ -448,6 +450,7 @@ pub(in crate::imp) unsafe fn syscall5_readonly(
448450
a4: ArgReg<'_, A4>,
449451
) -> RetReg<R0> {
450452
let r0;
453+
// See the comments in `syscall5`.
451454
asm!(
452455
".ifnes \"{a3}\",\"esi\"",
453456
"xchg esi, {a3}",
@@ -479,14 +482,7 @@ pub(in crate::imp) unsafe fn syscall6(
479482
a5: ArgReg<'_, A5>,
480483
) -> RetReg<R0> {
481484
let r0;
482-
// Oof. a3 should go in esi, and a5 should go in ebp, and `asm!` won't
483-
// let us use either of those registers as operands. And we can't request
484-
// stack slots. And there are no other registers free. Use eax as a
485-
// temporary pointer to a slice, since it gets clobbered as the return
486-
// value anyway.
487-
//
488-
// This is another reason that syscalls should be compiler intrinsics
489-
// rather than inline asm.
485+
// See the comments in `indirect_syscall6`.
490486
asm!(
491487
"push ebp",
492488
"push esi",
@@ -518,6 +514,7 @@ pub(in crate::imp) unsafe fn syscall6_readonly(
518514
a5: ArgReg<'_, A5>,
519515
) -> RetReg<R0> {
520516
let r0;
517+
// See the comments in `indirect_syscall6`.
521518
asm!(
522519
"push ebp",
523520
"push esi",

0 commit comments

Comments
 (0)