github.com/bir3/gocompiler@v0.9.2202/src/internal/syscall/unix/fcntl_unix.go (about) 1 // Copyright 2023 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 unix 6 7 package unix 8 9 import ( 10 "syscall" 11 _ "unsafe" // for go:linkname 12 ) 13 14 // Implemented in the runtime package. 15 // 16 //go:linkname fcntl runtime.fcntl 17 func fcntl(fd int32, cmd int32, arg int32) (int32, int32) 18 19 func Fcntl(fd int, cmd int, arg int) (int, error) { 20 val, errno := fcntl(int32(fd), int32(cmd), int32(arg)) 21 if val == -1 { 22 return int(val), syscall.Errno(errno) 23 } 24 return int(val), nil 25 }