Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ia32/vfork: simplify assembly #314

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions arch/ia32/syscalls.S
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,17 @@ sym: \
.size sym, .-sym


.bss
vfork_address:
.space 4
.text
.globl vfork
.type vfork, @function
.align 4, 0x90
vfork:
mov (%esp), %eax
mov %eax, (vfork_address)
/* Save the return address as child will override parent's stack.
* Syscalls restore all registers but %eax thus %edx will not be overwritten.
* %edx is used as it need not to be restored before function exit. */
mov (%esp), %edx
agkaminski marked this conversation as resolved.
Show resolved Hide resolved
movl $4, %eax
int $0x80
cmp $0, %eax
jz vfork_child
push %eax
mov (vfork_address), %eax
mov %eax, 4(%esp)
pop %eax
ret
vfork_child:
mov $0, %eax
mov %edx, (%esp)
ret
.size vfork, .-vfork

Expand Down
Loading