1// Copyright 2019 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// +build dragonfly freebsd hurd linux netbsd openbsd
6
7package poll
8
9import (
10	"syscall"
11)
12
13// Use a helper function to call fcntl.  This is defined in C in
14// libgo/runtime.
15//extern __go_fcntl_uintptr
16func libc_fcntl(uintptr, uintptr, uintptr) (uintptr, uintptr)
17
18func fcntl(fd int, cmd int, arg int) (int, error) {
19	syscall.Entersyscall()
20	r, e := libc_fcntl(uintptr(fd), uintptr(cmd), uintptr(arg))
21	syscall.Exitsyscall()
22	if e != 0 {
23		return int(r), syscall.Errno(e)
24	}
25	return int(r), nil
26}
27