aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/internal
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2020-02-05 14:33:27 -0800
committerIan Lance Taylor <iant@golang.org>2020-02-15 09:14:10 -0800
commit0b3c2eed35d608d6541ecf004a9576b4eae0b4ef (patch)
treec92c05d53eb054d8085d069800f4e9b586fef5a3 /libgo/go/internal
parent17edb3310d8ce9d5f6c9e53f6c1f7d611c2a5a41 (diff)
downloadgcc-0b3c2eed35d608d6541ecf004a9576b4eae0b4ef.zip
gcc-0b3c2eed35d608d6541ecf004a9576b4eae0b4ef.tar.gz
gcc-0b3c2eed35d608d6541ecf004a9576b4eae0b4ef.tar.bz2
libgo: update to Go1.14rc1 release
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/218017
Diffstat (limited to 'libgo/go/internal')
-rw-r--r--libgo/go/internal/poll/fcntl_js.go14
-rw-r--r--libgo/go/internal/poll/fcntl_libc.go26
-rw-r--r--libgo/go/internal/poll/fcntl_syscall.go26
-rw-r--r--libgo/go/internal/poll/fd_fsync_darwin.go20
-rw-r--r--libgo/go/internal/poll/fd_fsync_posix.go15
-rw-r--r--libgo/go/internal/poll/fd_unix.go2
-rw-r--r--libgo/go/internal/syscall/unix/nonblocking.go2
-rw-r--r--libgo/go/internal/syscall/unix/nonblocking_libc.go (renamed from libgo/go/internal/syscall/unix/nonblocking_darwin.go)20
8 files changed, 77 insertions, 48 deletions
diff --git a/libgo/go/internal/poll/fcntl_js.go b/libgo/go/internal/poll/fcntl_js.go
new file mode 100644
index 0000000..120fc11
--- /dev/null
+++ b/libgo/go/internal/poll/fcntl_js.go
@@ -0,0 +1,14 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build js,wasm
+
+package poll
+
+import "syscall"
+
+// fcntl not supported on js/wasm
+func fcntl(fd int, cmd int, arg int) (int, error) {
+ return 0, syscall.ENOSYS
+}
diff --git a/libgo/go/internal/poll/fcntl_libc.go b/libgo/go/internal/poll/fcntl_libc.go
new file mode 100644
index 0000000..ed00f76
--- /dev/null
+++ b/libgo/go/internal/poll/fcntl_libc.go
@@ -0,0 +1,26 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build aix darwin solaris
+
+package poll
+
+import (
+ "syscall"
+)
+
+// Use a helper function to call fcntl. This is defined in C in
+// libgo/runtime.
+//extern __go_fcntl_uintptr
+func libc_fcntl(uintptr, uintptr, uintptr) (uintptr, uintptr)
+
+func fcntl(fd int, cmd int, arg int) (int, error) {
+ syscall.Entersyscall()
+ r, e := libc_fcntl(uintptr(fd), uintptr(cmd), uintptr(arg))
+ syscall.Exitsyscall()
+ if e != 0 {
+ return int(r), syscall.Errno(e)
+ }
+ return int(r), nil
+}
diff --git a/libgo/go/internal/poll/fcntl_syscall.go b/libgo/go/internal/poll/fcntl_syscall.go
new file mode 100644
index 0000000..d232e51
--- /dev/null
+++ b/libgo/go/internal/poll/fcntl_syscall.go
@@ -0,0 +1,26 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build dragonfly freebsd linux netbsd openbsd
+
+package poll
+
+import (
+ "syscall"
+)
+
+// Use a helper function to call fcntl. This is defined in C in
+// libgo/runtime.
+//extern __go_fcntl_uintptr
+func libc_fcntl(uintptr, uintptr, uintptr) (uintptr, uintptr)
+
+func fcntl(fd int, cmd int, arg int) (int, error) {
+ syscall.Entersyscall()
+ r, e := libc_fcntl(uintptr(fd), uintptr(cmd), uintptr(arg))
+ syscall.Exitsyscall()
+ if e != 0 {
+ return int(r), syscall.Errno(e)
+ }
+ return int(r), nil
+}
diff --git a/libgo/go/internal/poll/fd_fsync_darwin.go b/libgo/go/internal/poll/fd_fsync_darwin.go
index 6cd3f91..9175149 100644
--- a/libgo/go/internal/poll/fd_fsync_darwin.go
+++ b/libgo/go/internal/poll/fd_fsync_darwin.go
@@ -4,10 +4,7 @@
package poll
-import (
- "syscall"
- _ "unsafe" // for go:linkname
-)
+import "syscall"
// Fsync invokes SYS_FCNTL with SYS_FULLFSYNC because
// on OS X, SYS_FSYNC doesn't fully flush contents to disk.
@@ -21,18 +18,3 @@ func (fd *FD) Fsync() error {
_, e1 := fcntl(fd.Sysfd, syscall.F_FULLFSYNC, 0)
return e1
}
-
-// Use a helper function to call fcntl. This is defined in C in
-// libgo/runtime.
-//extern __go_fcntl_uintptr
-func libc_fcntl(uintptr, uintptr, uintptr) (uintptr, uintptr)
-
-func fcntl(fd int, cmd int, arg int) (int, error) {
- syscall.Entersyscall()
- r, e := libc_fcntl(uintptr(fd), uintptr(cmd), uintptr(arg))
- syscall.Exitsyscall()
- if e != 0 {
- return int(r), syscall.Errno(e)
- }
- return int(r), nil
-}
diff --git a/libgo/go/internal/poll/fd_fsync_posix.go b/libgo/go/internal/poll/fd_fsync_posix.go
index 67b76f8..dfc8b77 100644
--- a/libgo/go/internal/poll/fd_fsync_posix.go
+++ b/libgo/go/internal/poll/fd_fsync_posix.go
@@ -8,11 +8,6 @@ package poll
import "syscall"
-// Use a helper function to call fcntl. This is defined in C in
-// libgo/runtime.
-//extern __go_fcntl_uintptr
-func libc_fcntl(uintptr, uintptr, uintptr) (uintptr, uintptr)
-
// Fsync wraps syscall.Fsync.
func (fd *FD) Fsync() error {
if err := fd.incref(); err != nil {
@@ -21,13 +16,3 @@ func (fd *FD) Fsync() error {
defer fd.decref()
return syscall.Fsync(fd.Sysfd)
}
-
-func fcntl(fd int, cmd int, arg int) (int, error) {
- syscall.Entersyscall()
- r, e := libc_fcntl(uintptr(fd), uintptr(cmd), uintptr(arg))
- syscall.Exitsyscall()
- if e != 0 {
- return int(r), syscall.Errno(e)
- }
- return int(r), nil
-}
diff --git a/libgo/go/internal/poll/fd_unix.go b/libgo/go/internal/poll/fd_unix.go
index 6b8e476..213e815 100644
--- a/libgo/go/internal/poll/fd_unix.go
+++ b/libgo/go/internal/poll/fd_unix.go
@@ -451,7 +451,7 @@ var tryDupCloexec = int32(1)
// DupCloseOnExec dups fd and marks it close-on-exec.
func DupCloseOnExec(fd int) (int, string, error) {
- if atomic.LoadInt32(&tryDupCloexec) == 1 {
+ if syscall.F_DUPFD_CLOEXEC != 0 && atomic.LoadInt32(&tryDupCloexec) == 1 {
r0, e1 := fcntl(fd, syscall.F_DUPFD_CLOEXEC, 0)
if e1 == nil {
return r0, "", nil
diff --git a/libgo/go/internal/syscall/unix/nonblocking.go b/libgo/go/internal/syscall/unix/nonblocking.go
index cff5a53..9b39bb2 100644
--- a/libgo/go/internal/syscall/unix/nonblocking.go
+++ b/libgo/go/internal/syscall/unix/nonblocking.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build aix dragonfly freebsd hurd linux netbsd openbsd solaris
+// +build dragonfly freebsd linux netbsd openbsd
package unix
diff --git a/libgo/go/internal/syscall/unix/nonblocking_darwin.go b/libgo/go/internal/syscall/unix/nonblocking_libc.go
index e3dd3a0..464314d 100644
--- a/libgo/go/internal/syscall/unix/nonblocking_darwin.go
+++ b/libgo/go/internal/syscall/unix/nonblocking_libc.go
@@ -2,23 +2,19 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build darwin
+// +build aix darwin solaris
package unix
-import (
- "syscall"
- _ "unsafe" // for go:linkname
-)
+import "syscall"
+
+//extern __go_fcntl_uintptr
+func fcntl(uintptr, uintptr, uintptr) (uintptr, uintptr)
func IsNonblock(fd int) (nonblocking bool, err error) {
- flag, e1 := fcntl(fd, syscall.F_GETFL, 0)
- if e1 != nil {
- return false, e1
+ flag, e1 := fcntl(uintptr(fd), syscall.F_GETFL, 0)
+ if e1 != 0 {
+ return false, syscall.Errno(e1)
}
return flag&syscall.O_NONBLOCK != 0, nil
}
-
-// Implemented in syscall/syscall_darwin.go.
-//go:linkname fcntl syscall.fcntl
-func fcntl(fd int, cmd int, arg int) (int, error)