summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2013-07-31 23:38:53 -0700
committerBrad Fitzpatrick <bradfitz@golang.org>2013-07-31 23:38:53 -0700
commitad753d579768331ec2e351997dafcbd93b993f00 (patch)
treea08c22f67b5b0526f59a6070b23d7fa109f5ad84 /src
parentb1a748d9728063b2f2e860be5af52f11dc2efeaa (diff)
downloadgo-ad753d579768331ec2e351997dafcbd93b993f00.tar.gz
syscall: add Dup3 on Linux
With dup3, we can avoid an extra system call on some machines while holding syscall.ForkLock. Currently we have to syscall.Dup + syscall.CloseOnExec. On machines with Linux and a new enough kernel, this can just be dup3. R=golang-dev, r CC=golang-dev https://codereview.appspot.com/12170045
Diffstat (limited to 'src')
-rw-r--r--src/pkg/syscall/syscall_linux.go1
-rw-r--r--src/pkg/syscall/zsyscall_linux_386.go10
-rw-r--r--src/pkg/syscall/zsyscall_linux_amd64.go10
-rw-r--r--src/pkg/syscall/zsyscall_linux_arm.go10
4 files changed, 31 insertions, 0 deletions
diff --git a/src/pkg/syscall/syscall_linux.go b/src/pkg/syscall/syscall_linux.go
index b6d728e9f..79c1fda68 100644
--- a/src/pkg/syscall/syscall_linux.go
+++ b/src/pkg/syscall/syscall_linux.go
@@ -778,6 +778,7 @@ func Mount(source string, target string, fstype string, flags uintptr, data stri
//sys Creat(path string, mode uint32) (fd int, err error)
//sysnb Dup(oldfd int) (fd int, err error)
//sysnb Dup2(oldfd int, newfd int) (err error)
+//sysnb Dup3(oldfd int, newfd int, flags int) (err error)
//sysnb EpollCreate(size int) (fd int, err error)
//sysnb EpollCreate1(flag int) (fd int, err error)
//sysnb EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error)
diff --git a/src/pkg/syscall/zsyscall_linux_386.go b/src/pkg/syscall/zsyscall_linux_386.go
index 810cba004..6eeb11828 100644
--- a/src/pkg/syscall/zsyscall_linux_386.go
+++ b/src/pkg/syscall/zsyscall_linux_386.go
@@ -310,6 +310,16 @@ func Dup2(oldfd int, newfd int) (err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func Dup3(oldfd int, newfd int, flags int) (err error) {
+ _, _, e1 := RawSyscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags))
+ if e1 != 0 {
+ err = e1
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
func EpollCreate(size int) (fd int, err error) {
r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0)
fd = int(r0)
diff --git a/src/pkg/syscall/zsyscall_linux_amd64.go b/src/pkg/syscall/zsyscall_linux_amd64.go
index 9978b8138..c1c3d4511 100644
--- a/src/pkg/syscall/zsyscall_linux_amd64.go
+++ b/src/pkg/syscall/zsyscall_linux_amd64.go
@@ -310,6 +310,16 @@ func Dup2(oldfd int, newfd int) (err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func Dup3(oldfd int, newfd int, flags int) (err error) {
+ _, _, e1 := RawSyscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags))
+ if e1 != 0 {
+ err = e1
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
func EpollCreate(size int) (fd int, err error) {
r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0)
fd = int(r0)
diff --git a/src/pkg/syscall/zsyscall_linux_arm.go b/src/pkg/syscall/zsyscall_linux_arm.go
index 80d3f9b39..3380714a6 100644
--- a/src/pkg/syscall/zsyscall_linux_arm.go
+++ b/src/pkg/syscall/zsyscall_linux_arm.go
@@ -310,6 +310,16 @@ func Dup2(oldfd int, newfd int) (err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func Dup3(oldfd int, newfd int, flags int) (err error) {
+ _, _, e1 := RawSyscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags))
+ if e1 != 0 {
+ err = e1
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
func EpollCreate(size int) (fd int, err error) {
r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0)
fd = int(r0)