From 1775db3f06b568179d273425900dd09125831dd5 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Sun, 6 Jan 2019 09:38:07 -0800 Subject: [PATCH] unix: make Fcntl* routines use libSystem on Darwin Missed this one. Update golang/go#17490. Change-Id: I5ab2197f9981b712b37d3060f72209bebcadf291 Reviewed-on: https://go-review.googlesource.com/c/156346 Run-TryBot: Keith Randall TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- unix/fcntl.go | 2 +- unix/fcntl_darwin.go | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 unix/fcntl_darwin.go diff --git a/unix/fcntl.go b/unix/fcntl.go index 9379ba9c..39c03f1e 100644 --- a/unix/fcntl.go +++ b/unix/fcntl.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 darwin dragonfly freebsd linux netbsd openbsd +// +build dragonfly freebsd linux netbsd openbsd package unix diff --git a/unix/fcntl_darwin.go b/unix/fcntl_darwin.go new file mode 100644 index 00000000..5868a4a4 --- /dev/null +++ b/unix/fcntl_darwin.go @@ -0,0 +1,18 @@ +// 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 unix + +import "unsafe" + +// FcntlInt performs a fcntl syscall on fd with the provided command and argument. +func FcntlInt(fd uintptr, cmd, arg int) (int, error) { + return fcntl(int(fd), cmd, arg) +} + +// 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 { + _, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(lk)))) + return err +}