aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/net/fcntl_syscall_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/net/fcntl_syscall_test.go')
-rw-r--r--libgo/go/net/fcntl_syscall_test.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/libgo/go/net/fcntl_syscall_test.go b/libgo/go/net/fcntl_syscall_test.go
new file mode 100644
index 0000000..59ba1a1
--- /dev/null
+++ b/libgo/go/net/fcntl_syscall_test.go
@@ -0,0 +1,27 @@
+// Copyright 2021 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.
+
+//go:build dragonfly || freebsd || linux || netbsd || openbsd
+// +build dragonfly freebsd linux netbsd openbsd
+
+package net
+
+import (
+ "syscall"
+)
+
+// Use a helper function to call fcntl. This is defined in C in
+// libgo/runtime.
+//extern __go_fcntl_uintptr
+func libc_fcntl(uintptr, uintptr, uintptr) (uintptr, uintptr)
+
+func fcntl(fd int, cmd int, arg int) (int, error) {
+ syscall.Entersyscall()
+ r, e := libc_fcntl(uintptr(fd), uintptr(cmd), uintptr(arg))
+ syscall.Exitsyscall()
+ if e != 0 {
+ return int(r), syscall.Errno(e)
+ }
+ return int(r), nil
+}