--- /dev/null
+// 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.
+
+// On 32-bit Linux systems, use SYS_FCNTL64.
+// If you change the build tags here, see syscall/flock_linux_32bit.go.
+
+// +build linux,386 linux,arm linux,mips linux,mipsle
+
+package unix
+
+import "syscall"
+
+func init() {
+ FcntlSyscall = syscall.SYS_FCNTL64
+}
import "syscall"
+// FcntlSyscall is the number for the fcntl system call. This is
+// usually SYS_FCNTL, but can be overridden to SYS_FCNTL64.
+var FcntlSyscall uintptr = syscall.SYS_FCNTL
+
func IsNonblock(fd int) (nonblocking bool, err error) {
- flag, _, e1 := syscall.Syscall(syscall.SYS_FCNTL, uintptr(fd), uintptr(syscall.F_GETFL), 0)
+ flag, _, e1 := syscall.Syscall(FcntlSyscall, uintptr(fd), uintptr(syscall.F_GETFL), 0)
if e1 != 0 {
return false, e1
}
--- /dev/null
+// 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.
+
+package runtime
+
+func Fcntl(fd, cmd, arg uintptr) (uintptr, uintptr) {
+ r := fcntl(int32(fd), int32(cmd), int32(arg))
+ if r < 0 {
+ return ^uintptr(0), uintptr(-r)
+ }
+ return uintptr(r), 0
+}
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build aix solaris
+// +build aix darwin solaris
package runtime_test
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build darwin dragonfly freebsd linux netbsd openbsd
+// +build dragonfly freebsd linux netbsd openbsd
package runtime_test
-import "syscall"
+import (
+ "internal/syscall/unix"
+ "syscall"
+)
func fcntl(fd uintptr, cmd int, arg uintptr) (uintptr, syscall.Errno) {
- res, _, err := syscall.Syscall(syscall.SYS_FCNTL, fd, uintptr(cmd), arg)
+ res, _, err := syscall.Syscall(unix.FcntlSyscall, fd, uintptr(cmd), arg)
return res, err
}
-// +build linux,386 linux,arm linux,mips linux,mipsle
-
// Copyright 2014 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.
+// If you change the build tags here, see
+// internal/syscall/unix/fcntl_linux_32bit.go.
+
+// +build linux,386 linux,arm linux,mips linux,mipsle
+
package syscall
func init() {