Debian Codegraph @

libgo/go/net/fcntl_libc_test.go

raw
1 // Copyright 2021 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 //go:build aix || darwin || solaris
6
7 package net
8
9 import (
10 "syscall"
11 _ "unsafe"
12 )
13
14 // Use a helper function to call fcntl. This is defined in C in
15 // libgo/runtime.
16 //extern __go_fcntl_uintptr
17 func libc_fcntl(uintptr, uintptr, uintptr) (uintptr, uintptr)
18
19 // Implemented in the syscall package.
20 //go:linkname fcntl syscall.fcntl
21 func fcntl(fd int, cmd int, arg int) (int, error) {
22 syscall.Entersyscall()
23 r, e := libc_fcntl(uintptr(fd), uintptr(cmd), uintptr(arg))
24 syscall.Exitsyscall()
25 if e != 0 {
26 return int(r), syscall.Errno(e)
27 }
28 return int(r), nil
29 }