Commit 372efbbf authored by Ian Lance Taylor's avatar Ian Lance Taylor

internal/syscall/unix: use fcntl64 on 32-bit GNU/Linux systems

Patch up runtime testing to use the libc fcntl function on Darwin,
which is what we should be doing anyhow. This is similar to how
we handle fcntl on AIX and Solaris.

Fixes #36211

Change-Id: I47ad87e11df043ce21496a0d59523dad28960f76
Reviewed-on: https://go-review.googlesource.com/c/go/+/212299
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarTobias Klauser <tobias.klauser@gmail.com>
parent 26f8b707
// 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
}
...@@ -8,8 +8,12 @@ package unix ...@@ -8,8 +8,12 @@ package unix
import "syscall" 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) { 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 { if e1 != 0 {
return false, e1 return false, e1
} }
......
// 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
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// +build aix solaris // +build aix darwin solaris
package runtime_test package runtime_test
......
...@@ -2,13 +2,16 @@ ...@@ -2,13 +2,16 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 package runtime_test
import "syscall" import (
"internal/syscall/unix"
"syscall"
)
func fcntl(fd uintptr, cmd int, arg uintptr) (uintptr, syscall.Errno) { 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 return res, err
} }
// +build linux,386 linux,arm linux,mips linux,mipsle
// Copyright 2014 The Go Authors. All rights reserved. // Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 package syscall
func init() { func init() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment