forked from jsgilmore/ib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
syscall_linux_amd64.go
71 lines (63 loc) · 1.22 KB
/
syscall_linux_amd64.go
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Created by cgo -godefs - DO NOT EDIT
// cgo -godefs syscall_linux.go
package ib
import (
"syscall"
"unsafe"
)
const (
POLLIN = 0x1
POLLPRI = 0x2
POLLOUT = 0x4
POLLRDHUP = 0x2000
POLLERR = 0x8
POLLHUP = 0x10
POLLNVAL = 0x20
)
const (
RLIM_INFINITY = -0x1
RLIMIT_AS = 0x9
RLIMIT_CORE = 0x4
RLIMIT_CPU = 0x0
RLIMIT_DATA = 0x2
RLIMIT_FSIZE = 0x1
RLIMIT_MEMLOCK = 0x8
RLIMIT_MSGQUEUE = 0xc
RLIMIT_NICE = 0xd
RLIMIT_NOFILE = 0x7
RLIMIT_NPROC = 0x6
RLIMIT_RSS = 0x5
RLIMIT_RTPRIO = 0xe
RLIMIT_SIGPENDING = 0xb
RLIMIT_STACK = 0x3
)
type Pollfd struct {
Fd int32
Events int16
Revents int16
}
type Rlimit struct {
Cur uint64
Max uint64
}
func Getrlimit(resource int) (rlim Rlimit, err error) {
_, _, e1 := syscall.Syscall(syscall.SYS_GETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(&rlim)), 0)
if e1 != 0 {
err = e1
}
return
}
func Poll(fds []Pollfd, timeout int64) (n int, err error) {
for {
r0, _, e1 := syscall.Syscall(syscall.SYS_POLL, uintptr(unsafe.Pointer(&fds[0])), uintptr(len(fds)), uintptr(timeout))
n = int(r0)
switch e1 {
case 0:
return
case 0x4:
default:
err = e1
return
}
}
}