-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
system(syscall): switch to x/sys (#963)
- Loading branch information
1 parent
1e2a4d8
commit ad12eac
Showing
12 changed files
with
61 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,32 @@ | ||
package system | ||
|
||
import ( | ||
"syscall" | ||
"unsafe" | ||
|
||
"golang.org/x/sys/unix" | ||
) | ||
|
||
// SyscallErrno wraps the "unix.Errno" | ||
type SyscallErrno unix.Errno | ||
|
||
// wrapping for used constants of unix package | ||
const ( | ||
Syscall_SYS_IOCTL = unix.SYS_IOCTL | ||
Syscall_EINVAL = unix.EINVAL | ||
Syscall_EBUSY = unix.EBUSY | ||
Syscall_EFAULT = unix.EFAULT | ||
) | ||
|
||
// nativeSyscall represents the native Syscall | ||
type nativeSyscall struct{} | ||
|
||
// Syscall calls the native syscall.Syscall, implements the SystemCaller interface | ||
func (sys *nativeSyscall) syscall(trap uintptr, f File, signal uintptr, payload unsafe.Pointer) (r1, r2 uintptr, err syscall.Errno) { | ||
return syscall.Syscall(trap, f.Fd(), signal, uintptr(payload)) | ||
// Syscall calls the native unix.Syscall, implements the SystemCaller interface | ||
func (sys *nativeSyscall) syscall(trap uintptr, f File, signal uintptr, payload unsafe.Pointer) (r1, r2 uintptr, err SyscallErrno) { | ||
r1, r2, errNo := unix.Syscall(trap, f.Fd(), signal, uintptr(payload)) | ||
return r1, r2, SyscallErrno(errNo) | ||
} | ||
|
||
// Error implements the error interface. It wraps the "unix.Errno.Error()". | ||
func (e SyscallErrno) Error() string { | ||
return unix.Errno(e).Error() | ||
} |
Oops, something went wrong.