Skip to content

Commit

Permalink
Provide optimized assembly for PPOLL blocking syscall on i386
Browse files Browse the repository at this point in the history
  • Loading branch information
fako1024 committed Sep 7, 2023
1 parent 8e23f5f commit 8b4a859
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
24 changes: 24 additions & 0 deletions event/poll_386.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "textflag.h"

#define INVOKE_SYSCALL INT $0x80
#define SYS__PPOLL 0x135

// func pollBlock(fds *unix.PollFd, nfds int) (err syscall.Errno)
TEXT ·pollBlock(SB),NOSPLIT,$0-12
CALL runtime·entersyscallblock(SB) // Call blocking SYSCALL directive from runtime package
MOVL $SYS__PPOLL, AX // Prepare / perform ppoll() SYSCALL
MOVL fds+0(FP), BX // PollFDs parameter
MOVL nfds+4(FP), CX // Put nFDs parameter
MOVL $0x0, DX // Put timeout parameter (set to NULL)
MOVL $0x0, SI // Put sigmask parameter (skip)
INVOKE_SYSCALL
CMPL AX, $0xfffff002 // No error / EINTR
JLS success // Jump to success
NEGL AX // Negate SYSCALL errno
MOVL AX, err+8(FP) // Store error code in err return value
CALL runtime·exitsyscall(SB) // Finalize SYSCALL using the directive from runtime package
RET // Return
success:
MOVL $0, err+8(FP) // Store NULL error code in err return value
CALL runtime·exitsyscall(SB) // Finalize SYSCALL using the directive from runtime package
RET // Return
4 changes: 2 additions & 2 deletions event/poll_asm.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build (linux && amd64) || (linux && arm64) || (linux && arm)
// +build linux,amd64 linux,arm64 linux,arm
//go:build (linux && amd64) || (linux && arm64) || (linux && arm) || (linux && 386)
// +build linux,amd64 linux,arm64 linux,arm linux,386

package event

Expand Down
4 changes: 2 additions & 2 deletions event/poll_default.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build linux && !amd64 && !arm64 && !arm
// +build linux,!amd64,!arm64,!arm
//go:build linux && !amd64 && !arm64 && !arm && !386
// +build linux,!amd64,!arm64,!arm,!386

package event

Expand Down

0 comments on commit 8b4a859

Please sign in to comment.