Skip to content

Commit

Permalink
ia32/vfork: simplify assembly
Browse files Browse the repository at this point in the history
JIRA: RTOS-697
  • Loading branch information
badochov committed Nov 30, 2023
1 parent a8ac6ed commit ef10873
Showing 1 changed file with 5 additions and 15 deletions.
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
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

0 comments on commit ef10873

Please sign in to comment.