x64-httpd/poll_remove.s

35 lines
735 B
ArmAsm

; Returns new array length in rax
; edi - fd
pollfds__remove:
mov r10d, edi
mov rdi, [pollfds_len]
; Variables:
; rdi - array length
; rsi - array index
; r10d - fd
; r11d - pollfds[rdi].fd
pollfds__remove__loop:
cmp rsi, rdi
jge return ; fd was not found
mov r11d, [pollfds + rsi * pollfd_size]
add rsi, 1
cmp r11d, r10d
jne pollfds__remove__loop
sub rsi, 1
; Returns new array length in rax
; rdi - array length
; rsi - array index to remove
pollfds__remove_index:
cmp rdi, 1
jle pollfds__clear
mov r10d, [pollfds + (rdi - 1) * pollfd_size]
mov [pollfds + rsi * pollfd_size], r10d
sub rdi, 1
ret
; Returns new array length in rax
pollfds__clear:
mov rax, 0
ret