-
Notifications
You must be signed in to change notification settings - Fork 900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime: add runtime.fnctl link directives #4481
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -212,6 +212,24 @@ func Truncate(path string, length int64) (err error) { | |
return | ||
} | ||
|
||
/* | ||
//go:linkname syscall_fcntl runtime/runtime.fcntl | ||
func syscall_fcntl(fd, cmd, arg int32) (ret int32, errno int32) { | ||
// https://cs.opensource.google/go/go/+/master:src/runtime/os_linux.go;l=452?q=runtime.fcntl&ss=go%2Fgo | ||
r, _, err := Syscall6(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg), 0, 0, 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you trying to do a direct system call in syscall_libc.go? What about calling the libc function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Creating a wrapper to the libc sounds like a good idea. |
||
return int32(r), int32(err) | ||
} | ||
*/ | ||
|
||
//go:linkname Fcntl runtime/runtime.fcntl | ||
func Fcntl(fd int, cmd int, args ...int) (int, error) { | ||
ret := libc_fcntl(fd, cmd, args...) | ||
if ret < 0 { | ||
return 0, getErrno() | ||
} | ||
return ret, nil | ||
} | ||
|
||
func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) | ||
|
||
func Kill(pid int, sig Signal) (err error) { | ||
|
@@ -465,3 +483,8 @@ func libc_execve(filename *byte, argv **byte, envp **byte) int | |
// | ||
//export truncate | ||
func libc_truncate(path *byte, length int64) int32 | ||
|
||
// int fcntl(int, int, ...); | ||
// | ||
// export fcntl | ||
func libc_fcntl(fd int, cmd int, args ...int) int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you meant
runtime.fcntl
?