Skip to content

Commit 4e6f963

Browse files
dAdAbirdgopherbot
authored andcommitted
runtime: move epoll syscalls to runtime/internal/syscall
This change moves Linux epoll's syscalls implementation to the "runtime/internal/syscall" package. The intention in this CL was to minimise behavioural changes but make the code more generalised. This also will allow adding new syscalls (like epoll_pwait2) without the need to implement assembly stubs for each arch. It also drops epoll_create as not all architectures provide this call. epoll_create1 was added to the kernel in version 2.6.27 and Go requires Linux kernel version 2.6.32 or later since Go 1.18. So it is safe to always use epoll_create1. For #53824 For #51087 Change-Id: I9a6a26b7f2075a38e041de1bab4691da0ecb94fc Reviewed-on: https://go-review.googlesource.com/c/go/+/421994 Reviewed-by: Michael Pratt <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Run-TryBot: Michael Pratt <[email protected]> Auto-Submit: Michael Pratt <[email protected]>
1 parent 9e0149d commit 4e6f963

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+411
-813
lines changed

src/runtime/defs2_linux.go

-11
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,6 @@ const (
121121

122122
O_RDONLY = C.O_RDONLY
123123
O_CLOEXEC = C.O_CLOEXEC
124-
125-
EPOLLIN = C.POLLIN
126-
EPOLLOUT = C.POLLOUT
127-
EPOLLERR = C.POLLERR
128-
EPOLLHUP = C.POLLHUP
129-
EPOLLRDHUP = C.POLLRDHUP
130-
EPOLLET = C.EPOLLET
131-
EPOLL_CLOEXEC = C.EPOLL_CLOEXEC
132-
EPOLL_CTL_ADD = C.EPOLL_CTL_ADD
133-
EPOLL_CTL_DEL = C.EPOLL_CTL_DEL
134-
EPOLL_CTL_MOD = C.EPOLL_CTL_MOD
135124
)
136125

137126
type Fpreg C.struct__fpreg

src/runtime/defs_linux.go

-12
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,6 @@ const (
115115
CLOCK_THREAD_CPUTIME_ID = C.CLOCK_THREAD_CPUTIME_ID
116116

117117
SIGEV_THREAD_ID = C.SIGEV_THREAD_ID
118-
119-
EPOLLIN = C.POLLIN
120-
EPOLLOUT = C.POLLOUT
121-
EPOLLERR = C.POLLERR
122-
EPOLLHUP = C.POLLHUP
123-
EPOLLRDHUP = C.POLLRDHUP
124-
EPOLLET = C.EPOLLET
125-
EPOLL_CLOEXEC = C.EPOLL_CLOEXEC
126-
EPOLL_CTL_ADD = C.EPOLL_CTL_ADD
127-
EPOLL_CTL_DEL = C.EPOLL_CTL_DEL
128-
EPOLL_CTL_MOD = C.EPOLL_CTL_MOD
129118
)
130119

131120
type Sigset C.sigset_t
@@ -136,4 +125,3 @@ type Siginfo C.siginfo_t
136125
type Itimerspec C.struct_itimerspec
137126
type Itimerval C.struct_itimerval
138127
type Sigevent C.struct_sigevent
139-
type EpollEvent C.struct_epoll_event

src/runtime/defs_linux_386.go

-16
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,6 @@ const (
9393
_O_NONBLOCK = 0x800
9494
_O_CLOEXEC = 0x80000
9595

96-
_EPOLLIN = 0x1
97-
_EPOLLOUT = 0x4
98-
_EPOLLERR = 0x8
99-
_EPOLLHUP = 0x10
100-
_EPOLLRDHUP = 0x2000
101-
_EPOLLET = 0x80000000
102-
_EPOLL_CLOEXEC = 0x80000
103-
_EPOLL_CTL_ADD = 0x1
104-
_EPOLL_CTL_DEL = 0x2
105-
_EPOLL_CTL_MOD = 0x3
106-
10796
_AF_UNIX = 0x1
10897
_SOCK_DGRAM = 0x2
10998
)
@@ -254,11 +243,6 @@ type sigevent struct {
254243
_ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte
255244
}
256245

257-
type epollevent struct {
258-
events uint32
259-
data [8]byte // to match amd64
260-
}
261-
262246
type sockaddr_un struct {
263247
family uint16
264248
path [108]byte

src/runtime/defs_linux_amd64.go

-16
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,6 @@ const (
8989

9090
_SIGEV_THREAD_ID = 0x4
9191

92-
_EPOLLIN = 0x1
93-
_EPOLLOUT = 0x4
94-
_EPOLLERR = 0x8
95-
_EPOLLHUP = 0x10
96-
_EPOLLRDHUP = 0x2000
97-
_EPOLLET = 0x80000000
98-
_EPOLL_CLOEXEC = 0x80000
99-
_EPOLL_CTL_ADD = 0x1
100-
_EPOLL_CTL_DEL = 0x2
101-
_EPOLL_CTL_MOD = 0x3
102-
10392
_AF_UNIX = 0x1
10493
_SOCK_DGRAM = 0x2
10594
)
@@ -171,11 +160,6 @@ type sigevent struct {
171160
_ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte
172161
}
173162

174-
type epollevent struct {
175-
events uint32
176-
data [8]byte // unaligned uintptr
177-
}
178-
179163
// created by cgo -cdefs and then converted to Go
180164
// cgo -cdefs defs_linux.go defs1_linux.go
181165

src/runtime/defs_linux_arm.go

-17
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,6 @@ const (
8787

8888
_SIGEV_THREAD_ID = 0x4
8989

90-
_EPOLLIN = 0x1
91-
_EPOLLOUT = 0x4
92-
_EPOLLERR = 0x8
93-
_EPOLLHUP = 0x10
94-
_EPOLLRDHUP = 0x2000
95-
_EPOLLET = 0x80000000
96-
_EPOLL_CLOEXEC = 0x80000
97-
_EPOLL_CTL_ADD = 0x1
98-
_EPOLL_CTL_DEL = 0x2
99-
_EPOLL_CTL_MOD = 0x3
100-
10190
_AF_UNIX = 0x1
10291
_SOCK_DGRAM = 0x2
10392
)
@@ -208,12 +197,6 @@ type sigactiont struct {
208197
sa_mask uint64
209198
}
210199

211-
type epollevent struct {
212-
events uint32
213-
_pad uint32
214-
data [8]byte // to match amd64
215-
}
216-
217200
type sockaddr_un struct {
218201
family uint16
219202
path [108]byte

src/runtime/defs_linux_arm64.go

-17
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,6 @@ const (
8989

9090
_SIGEV_THREAD_ID = 0x4
9191

92-
_EPOLLIN = 0x1
93-
_EPOLLOUT = 0x4
94-
_EPOLLERR = 0x8
95-
_EPOLLHUP = 0x10
96-
_EPOLLRDHUP = 0x2000
97-
_EPOLLET = 0x80000000
98-
_EPOLL_CLOEXEC = 0x80000
99-
_EPOLL_CTL_ADD = 0x1
100-
_EPOLL_CTL_DEL = 0x2
101-
_EPOLL_CTL_MOD = 0x3
102-
10392
_AF_UNIX = 0x1
10493
_SOCK_DGRAM = 0x2
10594
)
@@ -171,12 +160,6 @@ type sigevent struct {
171160
_ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte
172161
}
173162

174-
type epollevent struct {
175-
events uint32
176-
_pad uint32
177-
data [8]byte // to match amd64
178-
}
179-
180163
// Created by cgo -cdefs and then converted to Go by hand
181164
// ../cmd/cgo/cgo -cdefs defs_linux.go defs1_linux.go defs2_linux.go
182165

src/runtime/defs_linux_loong64.go

-17
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,6 @@ const (
8989
_CLOCK_THREAD_CPUTIME_ID = 0x3
9090

9191
_SIGEV_THREAD_ID = 0x4
92-
93-
_EPOLLIN = 0x1
94-
_EPOLLOUT = 0x4
95-
_EPOLLERR = 0x8
96-
_EPOLLHUP = 0x10
97-
_EPOLLRDHUP = 0x2000
98-
_EPOLLET = 0x80000000
99-
_EPOLL_CLOEXEC = 0x80000
100-
_EPOLL_CTL_ADD = 0x1
101-
_EPOLL_CTL_DEL = 0x2
102-
_EPOLL_CTL_MOD = 0x3
10392
)
10493

10594
type timespec struct {
@@ -146,12 +135,6 @@ type sigevent struct {
146135
_ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte
147136
}
148137

149-
type epollevent struct {
150-
events uint32
151-
pad_cgo_0 [4]byte
152-
data [8]byte // unaligned uintptr
153-
}
154-
155138
const (
156139
_O_RDONLY = 0x0
157140
_O_NONBLOCK = 0x800

src/runtime/defs_linux_mips64x.go

-17
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,6 @@ const (
9090
_CLOCK_THREAD_CPUTIME_ID = 0x3
9191

9292
_SIGEV_THREAD_ID = 0x4
93-
94-
_EPOLLIN = 0x1
95-
_EPOLLOUT = 0x4
96-
_EPOLLERR = 0x8
97-
_EPOLLHUP = 0x10
98-
_EPOLLRDHUP = 0x2000
99-
_EPOLLET = 0x80000000
100-
_EPOLL_CLOEXEC = 0x80000
101-
_EPOLL_CTL_ADD = 0x1
102-
_EPOLL_CTL_DEL = 0x2
103-
_EPOLL_CTL_MOD = 0x3
10493
)
10594

10695
//struct Sigset {
@@ -178,12 +167,6 @@ type sigevent struct {
178167
_ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte
179168
}
180169

181-
type epollevent struct {
182-
events uint32
183-
pad_cgo_0 [4]byte
184-
data [8]byte // unaligned uintptr
185-
}
186-
187170
const (
188171
_O_RDONLY = 0x0
189172
_O_NONBLOCK = 0x80

src/runtime/defs_linux_mipsx.go

-17
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,6 @@ const (
9090
_CLOCK_THREAD_CPUTIME_ID = 0x3
9191

9292
_SIGEV_THREAD_ID = 0x4
93-
94-
_EPOLLIN = 0x1
95-
_EPOLLOUT = 0x4
96-
_EPOLLERR = 0x8
97-
_EPOLLHUP = 0x10
98-
_EPOLLRDHUP = 0x2000
99-
_EPOLLET = 0x80000000
100-
_EPOLL_CLOEXEC = 0x80000
101-
_EPOLL_CTL_ADD = 0x1
102-
_EPOLL_CTL_DEL = 0x2
103-
_EPOLL_CTL_MOD = 0x3
10493
)
10594

10695
type timespec struct {
@@ -172,12 +161,6 @@ type sigevent struct {
172161
_ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte
173162
}
174163

175-
type epollevent struct {
176-
events uint32
177-
pad_cgo_0 [4]byte
178-
data uint64
179-
}
180-
181164
const (
182165
_O_RDONLY = 0x0
183166
_O_NONBLOCK = 0x80

src/runtime/defs_linux_ppc64.go

-17
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,6 @@ const (
8787
_CLOCK_THREAD_CPUTIME_ID = 0x3
8888

8989
_SIGEV_THREAD_ID = 0x4
90-
91-
_EPOLLIN = 0x1
92-
_EPOLLOUT = 0x4
93-
_EPOLLERR = 0x8
94-
_EPOLLHUP = 0x10
95-
_EPOLLRDHUP = 0x2000
96-
_EPOLLET = 0x80000000
97-
_EPOLL_CLOEXEC = 0x80000
98-
_EPOLL_CTL_ADD = 0x1
99-
_EPOLL_CTL_DEL = 0x2
100-
_EPOLL_CTL_MOD = 0x3
10190
)
10291

10392
//struct Sigset {
@@ -172,12 +161,6 @@ type sigevent struct {
172161
_ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte
173162
}
174163

175-
type epollevent struct {
176-
events uint32
177-
pad_cgo_0 [4]byte
178-
data [8]byte // unaligned uintptr
179-
}
180-
181164
// created by cgo -cdefs and then converted to Go
182165
// cgo -cdefs defs_linux.go defs3_linux.go
183166

src/runtime/defs_linux_ppc64le.go

-17
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,6 @@ const (
8787
_CLOCK_THREAD_CPUTIME_ID = 0x3
8888

8989
_SIGEV_THREAD_ID = 0x4
90-
91-
_EPOLLIN = 0x1
92-
_EPOLLOUT = 0x4
93-
_EPOLLERR = 0x8
94-
_EPOLLHUP = 0x10
95-
_EPOLLRDHUP = 0x2000
96-
_EPOLLET = 0x80000000
97-
_EPOLL_CLOEXEC = 0x80000
98-
_EPOLL_CTL_ADD = 0x1
99-
_EPOLL_CTL_DEL = 0x2
100-
_EPOLL_CTL_MOD = 0x3
10190
)
10291

10392
//struct Sigset {
@@ -172,12 +161,6 @@ type sigevent struct {
172161
_ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte
173162
}
174163

175-
type epollevent struct {
176-
events uint32
177-
pad_cgo_0 [4]byte
178-
data [8]byte // unaligned uintptr
179-
}
180-
181164
// created by cgo -cdefs and then converted to Go
182165
// cgo -cdefs defs_linux.go defs3_linux.go
183166

src/runtime/defs_linux_riscv64.go

-17
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,6 @@ const (
8989
_CLOCK_THREAD_CPUTIME_ID = 0x3
9090

9191
_SIGEV_THREAD_ID = 0x4
92-
93-
_EPOLLIN = 0x1
94-
_EPOLLOUT = 0x4
95-
_EPOLLERR = 0x8
96-
_EPOLLHUP = 0x10
97-
_EPOLLRDHUP = 0x2000
98-
_EPOLLET = 0x80000000
99-
_EPOLL_CLOEXEC = 0x80000
100-
_EPOLL_CTL_ADD = 0x1
101-
_EPOLL_CTL_DEL = 0x2
102-
_EPOLL_CTL_MOD = 0x3
10392
)
10493

10594
type timespec struct {
@@ -171,12 +160,6 @@ type sigevent struct {
171160
_ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte
172161
}
173162

174-
type epollevent struct {
175-
events uint32
176-
pad_cgo_0 [4]byte
177-
data [8]byte // unaligned uintptr
178-
}
179-
180163
const (
181164
_O_RDONLY = 0x0
182165
_O_NONBLOCK = 0x800

src/runtime/defs_linux_s390x.go

-17
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,6 @@ const (
8888
_CLOCK_THREAD_CPUTIME_ID = 0x3
8989

9090
_SIGEV_THREAD_ID = 0x4
91-
92-
_EPOLLIN = 0x1
93-
_EPOLLOUT = 0x4
94-
_EPOLLERR = 0x8
95-
_EPOLLHUP = 0x10
96-
_EPOLLRDHUP = 0x2000
97-
_EPOLLET = 0x80000000
98-
_EPOLL_CLOEXEC = 0x80000
99-
_EPOLL_CTL_ADD = 0x1
100-
_EPOLL_CTL_DEL = 0x2
101-
_EPOLL_CTL_MOD = 0x3
10291
)
10392

10493
type timespec struct {
@@ -168,12 +157,6 @@ type sigevent struct {
168157
_ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte
169158
}
170159

171-
type epollevent struct {
172-
events uint32
173-
pad_cgo_0 [4]byte
174-
data [8]byte // unaligned uintptr
175-
}
176-
177160
const (
178161
_O_RDONLY = 0x0
179162
_O_NONBLOCK = 0x800

0 commit comments

Comments
 (0)