unix: add FcntlInt

Fixes golang/go#24649
Fixes golang/go#24677

Change-Id: I3faa74ab68e093a097c3f2a8ec7c054431bdfb3f
Reviewed-on: https://go-review.googlesource.com/104736
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/unix/flock.go b/unix/fcntl.go
similarity index 74%
rename from unix/flock.go
rename to unix/fcntl.go
index 2994ce7..0c58c7e 100644
--- a/unix/flock.go
+++ b/unix/fcntl.go
@@ -12,6 +12,12 @@
 // systems by flock_linux_32bit.go to be SYS_FCNTL64.
 var fcntl64Syscall uintptr = SYS_FCNTL
 
+// FcntlInt performs a fcntl syscall on fd with the provided command and argument.
+func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
+	valptr, _, err := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(arg))
+	return int(valptr), err
+}
+
 // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
 func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
 	_, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))
diff --git a/unix/flock_linux_32bit.go b/unix/fcntl_linux_32bit.go
similarity index 100%
rename from unix/flock_linux_32bit.go
rename to unix/fcntl_linux_32bit.go
diff --git a/unix/syscall_solaris.go b/unix/syscall_solaris.go
index 76fe8e7..b762952 100644
--- a/unix/syscall_solaris.go
+++ b/unix/syscall_solaris.go
@@ -312,6 +312,12 @@
 
 //sys	fcntl(fd int, cmd int, arg int) (val int, err error)
 
+// FcntlInt performs a fcntl syscall on fd with the provided command and argument.
+func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
+	valptr, _, err := sysvicall6(uintptr(unsafe.Pointer(&procfcntl)), 3, uintptr(fd), uintptr(cmd), uintptr(arg), 0, 0, 0)
+	return int(valptr), err
+}
+
 // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
 func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
 	_, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procfcntl)), 3, uintptr(fd), uintptr(cmd), uintptr(unsafe.Pointer(lk)), 0, 0, 0)