1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
// Copyright 2016 The Netstack Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "textflag.h"
// blockingPoll makes the poll() syscall while calling the version of
// entersyscall that relinquishes the P so that other Gs can run. This is meant
// to be called in cases when the syscall is expected to block.
//
// func blockingPoll(fds *pollEvent, nfds int, timeout int64) (n int, err syscall.Errno)
TEXT ·blockingPoll(SB),NOSPLIT,$0-40
CALL runtime·entersyscallblock(SB)
MOVQ fds+0(FP), DI
MOVQ nfds+8(FP), SI
MOVQ timeout+16(FP), DX
MOVQ $0x7, AX // SYS_POLL
SYSCALL
CMPQ AX, $0xfffffffffffff001
JLS ok
MOVQ $-1, n+24(FP)
NEGQ AX
MOVQ AX, err+32(FP)
CALL runtime·exitsyscall(SB)
RET
ok:
MOVQ AX, n+24(FP)
MOVQ $0, err+32(FP)
CALL runtime·exitsyscall(SB)
RET
|