mirror of
https://github.com/rwinkhart/sys.git
synced 2026-08-27 20:36:31 -04:00
all: gofmt
Gofmt to update doc comments to the new formatting. For golang/go#51082. Change-Id: I9a1c4b671c06820a1c383ee515f7884965fefa54 Reviewed-on: https://go-review.googlesource.com/c/sys/+/399602 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Russ Cox <rsc@golang.org>
This commit is contained in:
+2
-2
@@ -106,8 +106,8 @@ var ARM64 struct {
|
|||||||
|
|
||||||
// ARM contains the supported CPU features of the current ARM (32-bit) platform.
|
// ARM contains the supported CPU features of the current ARM (32-bit) platform.
|
||||||
// All feature flags are false if:
|
// All feature flags are false if:
|
||||||
// 1. the current platform is not arm, or
|
// 1. the current platform is not arm, or
|
||||||
// 2. the current operating system is not Linux.
|
// 2. the current operating system is not Linux.
|
||||||
var ARM struct {
|
var ARM struct {
|
||||||
_ CacheLinePad
|
_ CacheLinePad
|
||||||
HasSWP bool // SWP instruction support
|
HasSWP bool // SWP instruction support
|
||||||
|
|||||||
+5
-5
@@ -10,11 +10,11 @@ This program reads a file containing function prototypes
|
|||||||
(like syscall_plan9.go) and generates system call bodies.
|
(like syscall_plan9.go) and generates system call bodies.
|
||||||
The prototypes are marked by lines beginning with "//sys"
|
The prototypes are marked by lines beginning with "//sys"
|
||||||
and read like func declarations if //sys is replaced by func, but:
|
and read like func declarations if //sys is replaced by func, but:
|
||||||
* The parameter lists must give a name for each argument.
|
- The parameter lists must give a name for each argument.
|
||||||
This includes return parameters.
|
This includes return parameters.
|
||||||
* The parameter lists must give a type for each argument:
|
- The parameter lists must give a type for each argument:
|
||||||
the (x, y, z int) shorthand is not allowed.
|
the (x, y, z int) shorthand is not allowed.
|
||||||
* If the return parameter is an error number, it must be named errno.
|
- If the return parameter is an error number, it must be named errno.
|
||||||
|
|
||||||
A line beginning with //sysnb is like //sys, except that the
|
A line beginning with //sysnb is like //sys, except that the
|
||||||
goroutine will not be suspended during the execution of the system
|
goroutine will not be suspended during the execution of the system
|
||||||
|
|||||||
@@ -113,5 +113,6 @@ func (tv *Timeval) Nano() int64 {
|
|||||||
|
|
||||||
// use is a no-op, but the compiler cannot see that it is.
|
// use is a no-op, but the compiler cannot see that it is.
|
||||||
// Calling use(p) ensures that p is kept live until that point.
|
// Calling use(p) ensures that p is kept live until that point.
|
||||||
|
//
|
||||||
//go:noescape
|
//go:noescape
|
||||||
func use(p unsafe.Pointer)
|
func use(p unsafe.Pointer)
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ func Write(fd int, p []byte) (n int, err error) {
|
|||||||
var ioSync int64
|
var ioSync int64
|
||||||
|
|
||||||
//sys fd2path(fd int, buf []byte) (err error)
|
//sys fd2path(fd int, buf []byte) (err error)
|
||||||
|
|
||||||
func Fd2path(fd int) (path string, err error) {
|
func Fd2path(fd int) (path string, err error) {
|
||||||
var buf [512]byte
|
var buf [512]byte
|
||||||
|
|
||||||
@@ -126,6 +127,7 @@ func Fd2path(fd int) (path string, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//sys pipe(p *[2]int32) (err error)
|
//sys pipe(p *[2]int32) (err error)
|
||||||
|
|
||||||
func Pipe(p []int) (err error) {
|
func Pipe(p []int) (err error) {
|
||||||
if len(p) != 2 {
|
if len(p) != 2 {
|
||||||
return syscall.ErrorString("bad arg in system call")
|
return syscall.ErrorString("bad arg in system call")
|
||||||
@@ -180,6 +182,7 @@ func (w Waitmsg) ExitStatus() int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//sys await(s []byte) (n int, err error)
|
//sys await(s []byte) (n int, err error)
|
||||||
|
|
||||||
func Await(w *Waitmsg) (err error) {
|
func Await(w *Waitmsg) (err error) {
|
||||||
var buf [512]byte
|
var buf [512]byte
|
||||||
var f [5][]byte
|
var f [5][]byte
|
||||||
@@ -301,42 +304,49 @@ func Getgroups() (gids []int, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//sys open(path string, mode int) (fd int, err error)
|
//sys open(path string, mode int) (fd int, err error)
|
||||||
|
|
||||||
func Open(path string, mode int) (fd int, err error) {
|
func Open(path string, mode int) (fd int, err error) {
|
||||||
fixwd()
|
fixwd()
|
||||||
return open(path, mode)
|
return open(path, mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
//sys create(path string, mode int, perm uint32) (fd int, err error)
|
//sys create(path string, mode int, perm uint32) (fd int, err error)
|
||||||
|
|
||||||
func Create(path string, mode int, perm uint32) (fd int, err error) {
|
func Create(path string, mode int, perm uint32) (fd int, err error) {
|
||||||
fixwd()
|
fixwd()
|
||||||
return create(path, mode, perm)
|
return create(path, mode, perm)
|
||||||
}
|
}
|
||||||
|
|
||||||
//sys remove(path string) (err error)
|
//sys remove(path string) (err error)
|
||||||
|
|
||||||
func Remove(path string) error {
|
func Remove(path string) error {
|
||||||
fixwd()
|
fixwd()
|
||||||
return remove(path)
|
return remove(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
//sys stat(path string, edir []byte) (n int, err error)
|
//sys stat(path string, edir []byte) (n int, err error)
|
||||||
|
|
||||||
func Stat(path string, edir []byte) (n int, err error) {
|
func Stat(path string, edir []byte) (n int, err error) {
|
||||||
fixwd()
|
fixwd()
|
||||||
return stat(path, edir)
|
return stat(path, edir)
|
||||||
}
|
}
|
||||||
|
|
||||||
//sys bind(name string, old string, flag int) (err error)
|
//sys bind(name string, old string, flag int) (err error)
|
||||||
|
|
||||||
func Bind(name string, old string, flag int) (err error) {
|
func Bind(name string, old string, flag int) (err error) {
|
||||||
fixwd()
|
fixwd()
|
||||||
return bind(name, old, flag)
|
return bind(name, old, flag)
|
||||||
}
|
}
|
||||||
|
|
||||||
//sys mount(fd int, afd int, old string, flag int, aname string) (err error)
|
//sys mount(fd int, afd int, old string, flag int, aname string) (err error)
|
||||||
|
|
||||||
func Mount(fd int, afd int, old string, flag int, aname string) (err error) {
|
func Mount(fd int, afd int, old string, flag int, aname string) (err error) {
|
||||||
fixwd()
|
fixwd()
|
||||||
return mount(fd, afd, old, flag, aname)
|
return mount(fd, afd, old, flag, aname)
|
||||||
}
|
}
|
||||||
|
|
||||||
//sys wstat(path string, edir []byte) (err error)
|
//sys wstat(path string, edir []byte) (err error)
|
||||||
|
|
||||||
func Wstat(path string, edir []byte) (err error) {
|
func Wstat(path string, edir []byte) (err error) {
|
||||||
fixwd()
|
fixwd()
|
||||||
return wstat(path, edir)
|
return wstat(path, edir)
|
||||||
|
|||||||
@@ -6,18 +6,20 @@
|
|||||||
// consts, funcs, and types into a common source file, per GOOS.
|
// consts, funcs, and types into a common source file, per GOOS.
|
||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// $ mkmerge -out MERGED FILE [FILE ...]
|
//
|
||||||
|
// $ mkmerge -out MERGED FILE [FILE ...]
|
||||||
//
|
//
|
||||||
// Example:
|
// Example:
|
||||||
// # Remove all common consts, funcs, and types from zerrors_linux_*.go
|
//
|
||||||
// # and write the common code into zerrors_linux.go
|
// # Remove all common consts, funcs, and types from zerrors_linux_*.go
|
||||||
// $ mkmerge -out zerrors_linux.go zerrors_linux_*.go
|
// # and write the common code into zerrors_linux.go
|
||||||
|
// $ mkmerge -out zerrors_linux.go zerrors_linux_*.go
|
||||||
//
|
//
|
||||||
// mkmerge performs the merge in the following steps:
|
// mkmerge performs the merge in the following steps:
|
||||||
// 1. Construct the set of common code that is identical in all
|
// 1. Construct the set of common code that is identical in all
|
||||||
// architecture-specific files.
|
// architecture-specific files.
|
||||||
// 2. Write this common code to the merged file.
|
// 2. Write this common code to the merged file.
|
||||||
// 3. Remove the common code from all architecture-specific files.
|
// 3. Remove the common code from all architecture-specific files.
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
// +build ignore
|
// +build ignore
|
||||||
|
|
||||||
// mkasm_darwin.go generates assembly trampolines to call libSystem routines from Go.
|
// mkasm_darwin.go generates assembly trampolines to call libSystem routines from Go.
|
||||||
//This program must be run after mksyscall.go.
|
// This program must be run after mksyscall.go.
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
+5
-5
@@ -10,11 +10,11 @@ This program reads a file containing function prototypes
|
|||||||
(like syscall_darwin.go) and generates system call bodies.
|
(like syscall_darwin.go) and generates system call bodies.
|
||||||
The prototypes are marked by lines beginning with "//sys"
|
The prototypes are marked by lines beginning with "//sys"
|
||||||
and read like func declarations if //sys is replaced by func, but:
|
and read like func declarations if //sys is replaced by func, but:
|
||||||
* The parameter lists must give a name for each argument.
|
- The parameter lists must give a name for each argument.
|
||||||
This includes return parameters.
|
This includes return parameters.
|
||||||
* The parameter lists must give a type for each argument:
|
- The parameter lists must give a type for each argument:
|
||||||
the (x, y, z int) shorthand is not allowed.
|
the (x, y, z int) shorthand is not allowed.
|
||||||
* If the return parameter is an error number, it must be named errno.
|
- If the return parameter is an error number, it must be named errno.
|
||||||
|
|
||||||
A line beginning with //sysnb is like //sys, except that the
|
A line beginning with //sysnb is like //sys, except that the
|
||||||
goroutine will not be suspended during the execution of the system
|
goroutine will not be suspended during the execution of the system
|
||||||
|
|||||||
@@ -10,15 +10,15 @@ This program reads a file containing function prototypes
|
|||||||
(like syscall_aix.go) and generates system call bodies.
|
(like syscall_aix.go) and generates system call bodies.
|
||||||
The prototypes are marked by lines beginning with "//sys"
|
The prototypes are marked by lines beginning with "//sys"
|
||||||
and read like func declarations if //sys is replaced by func, but:
|
and read like func declarations if //sys is replaced by func, but:
|
||||||
* The parameter lists must give a name for each argument.
|
- The parameter lists must give a name for each argument.
|
||||||
This includes return parameters.
|
This includes return parameters.
|
||||||
* The parameter lists must give a type for each argument:
|
- The parameter lists must give a type for each argument:
|
||||||
the (x, y, z int) shorthand is not allowed.
|
the (x, y, z int) shorthand is not allowed.
|
||||||
* If the return parameter is an error number, it must be named err.
|
- If the return parameter is an error number, it must be named err.
|
||||||
* If go func name needs to be different than its libc name,
|
- If go func name needs to be different than its libc name,
|
||||||
* or the function is not in libc, name could be specified
|
- or the function is not in libc, name could be specified
|
||||||
* at the end, after "=" sign, like
|
- at the end, after "=" sign, like
|
||||||
//sys getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error) = libsocket.getsockopt
|
//sys getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error) = libsocket.getsockopt
|
||||||
*/
|
*/
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ func Creat(path string, mode uint32) (fd int, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//sys utimes(path string, times *[2]Timeval) (err error)
|
//sys utimes(path string, times *[2]Timeval) (err error)
|
||||||
|
|
||||||
func Utimes(path string, tv []Timeval) error {
|
func Utimes(path string, tv []Timeval) error {
|
||||||
if len(tv) != 2 {
|
if len(tv) != 2 {
|
||||||
return EINVAL
|
return EINVAL
|
||||||
@@ -45,6 +46,7 @@ func Utimes(path string, tv []Timeval) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//sys utimensat(dirfd int, path string, times *[2]Timespec, flag int) (err error)
|
//sys utimensat(dirfd int, path string, times *[2]Timespec, flag int) (err error)
|
||||||
|
|
||||||
func UtimesNano(path string, ts []Timespec) error {
|
func UtimesNano(path string, ts []Timespec) error {
|
||||||
if len(ts) != 2 {
|
if len(ts) != 2 {
|
||||||
return EINVAL
|
return EINVAL
|
||||||
@@ -300,11 +302,13 @@ func direntNamlen(buf []byte) (uint64, bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//sys getdirent(fd int, buf []byte) (n int, err error)
|
//sys getdirent(fd int, buf []byte) (n int, err error)
|
||||||
|
|
||||||
func Getdents(fd int, buf []byte) (n int, err error) {
|
func Getdents(fd int, buf []byte) (n int, err error) {
|
||||||
return getdirent(fd, buf)
|
return getdirent(fd, buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
//sys wait4(pid Pid_t, status *_C_int, options int, rusage *Rusage) (wpid Pid_t, err error)
|
//sys wait4(pid Pid_t, status *_C_int, options int, rusage *Rusage) (wpid Pid_t, err error)
|
||||||
|
|
||||||
func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) {
|
func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) {
|
||||||
var status _C_int
|
var status _C_int
|
||||||
var r Pid_t
|
var r Pid_t
|
||||||
@@ -372,6 +376,7 @@ func (w WaitStatus) TrapCause() int { return -1 }
|
|||||||
//sys fcntl(fd int, cmd int, arg int) (val int, err error)
|
//sys fcntl(fd int, cmd int, arg int) (val int, err error)
|
||||||
|
|
||||||
//sys fsyncRange(fd int, how int, start int64, length int64) (err error) = fsync_range
|
//sys fsyncRange(fd int, how int, start int64, length int64) (err error) = fsync_range
|
||||||
|
|
||||||
func Fsync(fd int) error {
|
func Fsync(fd int) error {
|
||||||
return fsyncRange(fd, O_SYNC, 0, 0)
|
return fsyncRange(fd, O_SYNC, 0, 0)
|
||||||
}
|
}
|
||||||
@@ -536,6 +541,7 @@ func Poll(fds []PollFd, timeout int) (n int, err error) {
|
|||||||
//sys Getsystemcfg(label int) (n uint64)
|
//sys Getsystemcfg(label int) (n uint64)
|
||||||
|
|
||||||
//sys umount(target string) (err error)
|
//sys umount(target string) (err error)
|
||||||
|
|
||||||
func Unmount(target string, flags int) (err error) {
|
func Unmount(target string, flags int) (err error) {
|
||||||
if flags != 0 {
|
if flags != 0 {
|
||||||
// AIX doesn't have any flags for umount.
|
// AIX doesn't have any flags for umount.
|
||||||
|
|||||||
@@ -125,11 +125,13 @@ func Pipe2(p []int, flags int) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//sys extpread(fd int, p []byte, flags int, offset int64) (n int, err error)
|
//sys extpread(fd int, p []byte, flags int, offset int64) (n int, err error)
|
||||||
|
|
||||||
func pread(fd int, p []byte, offset int64) (n int, err error) {
|
func pread(fd int, p []byte, offset int64) (n int, err error) {
|
||||||
return extpread(fd, p, 0, offset)
|
return extpread(fd, p, 0, offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
//sys extpwrite(fd int, p []byte, flags int, offset int64) (n int, err error)
|
//sys extpwrite(fd int, p []byte, flags int, offset int64) (n int, err error)
|
||||||
|
|
||||||
func pwrite(fd int, p []byte, offset int64) (n int, err error) {
|
func pwrite(fd int, p []byte, offset int64) (n int, err error) {
|
||||||
return extpwrite(fd, p, 0, offset)
|
return extpwrite(fd, p, 0, offset)
|
||||||
}
|
}
|
||||||
|
|||||||
+56
-56
@@ -512,24 +512,24 @@ func (sa *SockaddrL2) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
|||||||
//
|
//
|
||||||
// Server example:
|
// Server example:
|
||||||
//
|
//
|
||||||
// fd, _ := Socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)
|
// fd, _ := Socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)
|
||||||
// _ = unix.Bind(fd, &unix.SockaddrRFCOMM{
|
// _ = unix.Bind(fd, &unix.SockaddrRFCOMM{
|
||||||
// Channel: 1,
|
// Channel: 1,
|
||||||
// Addr: [6]uint8{0, 0, 0, 0, 0, 0}, // BDADDR_ANY or 00:00:00:00:00:00
|
// Addr: [6]uint8{0, 0, 0, 0, 0, 0}, // BDADDR_ANY or 00:00:00:00:00:00
|
||||||
// })
|
// })
|
||||||
// _ = Listen(fd, 1)
|
// _ = Listen(fd, 1)
|
||||||
// nfd, sa, _ := Accept(fd)
|
// nfd, sa, _ := Accept(fd)
|
||||||
// fmt.Printf("conn addr=%v fd=%d", sa.(*unix.SockaddrRFCOMM).Addr, nfd)
|
// fmt.Printf("conn addr=%v fd=%d", sa.(*unix.SockaddrRFCOMM).Addr, nfd)
|
||||||
// Read(nfd, buf)
|
// Read(nfd, buf)
|
||||||
//
|
//
|
||||||
// Client example:
|
// Client example:
|
||||||
//
|
//
|
||||||
// fd, _ := Socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)
|
// fd, _ := Socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)
|
||||||
// _ = Connect(fd, &SockaddrRFCOMM{
|
// _ = Connect(fd, &SockaddrRFCOMM{
|
||||||
// Channel: 1,
|
// Channel: 1,
|
||||||
// Addr: [6]byte{0x11, 0x22, 0x33, 0xaa, 0xbb, 0xcc}, // CC:BB:AA:33:22:11
|
// Addr: [6]byte{0x11, 0x22, 0x33, 0xaa, 0xbb, 0xcc}, // CC:BB:AA:33:22:11
|
||||||
// })
|
// })
|
||||||
// Write(fd, []byte(`hello`))
|
// Write(fd, []byte(`hello`))
|
||||||
type SockaddrRFCOMM struct {
|
type SockaddrRFCOMM struct {
|
||||||
// Addr represents a bluetooth address, byte ordering is little-endian.
|
// Addr represents a bluetooth address, byte ordering is little-endian.
|
||||||
Addr [6]uint8
|
Addr [6]uint8
|
||||||
@@ -556,12 +556,12 @@ func (sa *SockaddrRFCOMM) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
|||||||
// The SockaddrCAN struct must be bound to the socket file descriptor
|
// The SockaddrCAN struct must be bound to the socket file descriptor
|
||||||
// using Bind before the CAN socket can be used.
|
// using Bind before the CAN socket can be used.
|
||||||
//
|
//
|
||||||
// // Read one raw CAN frame
|
// // Read one raw CAN frame
|
||||||
// fd, _ := Socket(AF_CAN, SOCK_RAW, CAN_RAW)
|
// fd, _ := Socket(AF_CAN, SOCK_RAW, CAN_RAW)
|
||||||
// addr := &SockaddrCAN{Ifindex: index}
|
// addr := &SockaddrCAN{Ifindex: index}
|
||||||
// Bind(fd, addr)
|
// Bind(fd, addr)
|
||||||
// frame := make([]byte, 16)
|
// frame := make([]byte, 16)
|
||||||
// Read(fd, frame)
|
// Read(fd, frame)
|
||||||
//
|
//
|
||||||
// The full SocketCAN documentation can be found in the linux kernel
|
// The full SocketCAN documentation can be found in the linux kernel
|
||||||
// archives at: https://www.kernel.org/doc/Documentation/networking/can.txt
|
// archives at: https://www.kernel.org/doc/Documentation/networking/can.txt
|
||||||
@@ -632,13 +632,13 @@ func (sa *SockaddrCANJ1939) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
|||||||
// Here is an example of using an AF_ALG socket with SHA1 hashing.
|
// Here is an example of using an AF_ALG socket with SHA1 hashing.
|
||||||
// The initial socket setup process is as follows:
|
// The initial socket setup process is as follows:
|
||||||
//
|
//
|
||||||
// // Open a socket to perform SHA1 hashing.
|
// // Open a socket to perform SHA1 hashing.
|
||||||
// fd, _ := unix.Socket(unix.AF_ALG, unix.SOCK_SEQPACKET, 0)
|
// fd, _ := unix.Socket(unix.AF_ALG, unix.SOCK_SEQPACKET, 0)
|
||||||
// addr := &unix.SockaddrALG{Type: "hash", Name: "sha1"}
|
// addr := &unix.SockaddrALG{Type: "hash", Name: "sha1"}
|
||||||
// unix.Bind(fd, addr)
|
// unix.Bind(fd, addr)
|
||||||
// // Note: unix.Accept does not work at this time; must invoke accept()
|
// // Note: unix.Accept does not work at this time; must invoke accept()
|
||||||
// // manually using unix.Syscall.
|
// // manually using unix.Syscall.
|
||||||
// hashfd, _, _ := unix.Syscall(unix.SYS_ACCEPT, uintptr(fd), 0, 0)
|
// hashfd, _, _ := unix.Syscall(unix.SYS_ACCEPT, uintptr(fd), 0, 0)
|
||||||
//
|
//
|
||||||
// Once a file descriptor has been returned from Accept, it may be used to
|
// Once a file descriptor has been returned from Accept, it may be used to
|
||||||
// perform SHA1 hashing. The descriptor is not safe for concurrent use, but
|
// perform SHA1 hashing. The descriptor is not safe for concurrent use, but
|
||||||
@@ -647,39 +647,39 @@ func (sa *SockaddrCANJ1939) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
|||||||
// When hashing a small byte slice or string, a single Write and Read may
|
// When hashing a small byte slice or string, a single Write and Read may
|
||||||
// be used:
|
// be used:
|
||||||
//
|
//
|
||||||
// // Assume hashfd is already configured using the setup process.
|
// // Assume hashfd is already configured using the setup process.
|
||||||
// hash := os.NewFile(hashfd, "sha1")
|
// hash := os.NewFile(hashfd, "sha1")
|
||||||
// // Hash an input string and read the results. Each Write discards
|
// // Hash an input string and read the results. Each Write discards
|
||||||
// // previous hash state. Read always reads the current state.
|
// // previous hash state. Read always reads the current state.
|
||||||
// b := make([]byte, 20)
|
// b := make([]byte, 20)
|
||||||
// for i := 0; i < 2; i++ {
|
// for i := 0; i < 2; i++ {
|
||||||
// io.WriteString(hash, "Hello, world.")
|
// io.WriteString(hash, "Hello, world.")
|
||||||
// hash.Read(b)
|
// hash.Read(b)
|
||||||
// fmt.Println(hex.EncodeToString(b))
|
// fmt.Println(hex.EncodeToString(b))
|
||||||
// }
|
// }
|
||||||
// // Output:
|
// // Output:
|
||||||
// // 2ae01472317d1935a84797ec1983ae243fc6aa28
|
// // 2ae01472317d1935a84797ec1983ae243fc6aa28
|
||||||
// // 2ae01472317d1935a84797ec1983ae243fc6aa28
|
// // 2ae01472317d1935a84797ec1983ae243fc6aa28
|
||||||
//
|
//
|
||||||
// For hashing larger byte slices, or byte streams such as those read from
|
// For hashing larger byte slices, or byte streams such as those read from
|
||||||
// a file or socket, use Sendto with MSG_MORE to instruct the kernel to update
|
// a file or socket, use Sendto with MSG_MORE to instruct the kernel to update
|
||||||
// the hash digest instead of creating a new one for a given chunk and finalizing it.
|
// the hash digest instead of creating a new one for a given chunk and finalizing it.
|
||||||
//
|
//
|
||||||
// // Assume hashfd and addr are already configured using the setup process.
|
// // Assume hashfd and addr are already configured using the setup process.
|
||||||
// hash := os.NewFile(hashfd, "sha1")
|
// hash := os.NewFile(hashfd, "sha1")
|
||||||
// // Hash the contents of a file.
|
// // Hash the contents of a file.
|
||||||
// f, _ := os.Open("/tmp/linux-4.10-rc7.tar.xz")
|
// f, _ := os.Open("/tmp/linux-4.10-rc7.tar.xz")
|
||||||
// b := make([]byte, 4096)
|
// b := make([]byte, 4096)
|
||||||
// for {
|
// for {
|
||||||
// n, err := f.Read(b)
|
// n, err := f.Read(b)
|
||||||
// if err == io.EOF {
|
// if err == io.EOF {
|
||||||
// break
|
// break
|
||||||
// }
|
// }
|
||||||
// unix.Sendto(hashfd, b[:n], unix.MSG_MORE, addr)
|
// unix.Sendto(hashfd, b[:n], unix.MSG_MORE, addr)
|
||||||
// }
|
// }
|
||||||
// hash.Read(b)
|
// hash.Read(b)
|
||||||
// fmt.Println(hex.EncodeToString(b))
|
// fmt.Println(hex.EncodeToString(b))
|
||||||
// // Output: 85cdcad0c06eef66f805ecce353bec9accbeecc5
|
// // Output: 85cdcad0c06eef66f805ecce353bec9accbeecc5
|
||||||
//
|
//
|
||||||
// For more information, see: http://www.chronox.de/crypto-API/crypto/userspace-if.html.
|
// For more information, see: http://www.chronox.de/crypto-API/crypto/userspace-if.html.
|
||||||
type SockaddrALG struct {
|
type SockaddrALG struct {
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ func Pipe(p []int) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//sysnb pipe2(p *[2]_C_int, flags int) (err error)
|
//sysnb pipe2(p *[2]_C_int, flags int) (err error)
|
||||||
|
|
||||||
func Pipe2(p []int, flags int) error {
|
func Pipe2(p []int, flags int) error {
|
||||||
if len(p) != 2 {
|
if len(p) != 2 {
|
||||||
return EINVAL
|
return EINVAL
|
||||||
@@ -95,6 +96,7 @@ func Pipe2(p []int, flags int) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//sys Getdents(fd int, buf []byte) (n int, err error)
|
//sys Getdents(fd int, buf []byte) (n int, err error)
|
||||||
|
|
||||||
func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
|
func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
|
||||||
n, err = Getdents(fd, buf)
|
n, err = Getdents(fd, buf)
|
||||||
if err != nil || basep == nil {
|
if err != nil || basep == nil {
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ import (
|
|||||||
// in http://msdn.microsoft.com/en-us/library/ms880421.
|
// in http://msdn.microsoft.com/en-us/library/ms880421.
|
||||||
// This function returns "" (2 double quotes) if s is empty.
|
// This function returns "" (2 double quotes) if s is empty.
|
||||||
// Alternatively, these transformations are done:
|
// Alternatively, these transformations are done:
|
||||||
// - every back slash (\) is doubled, but only if immediately
|
// - every back slash (\) is doubled, but only if immediately
|
||||||
// followed by double quote (");
|
// followed by double quote (");
|
||||||
// - every double quote (") is escaped by back slash (\);
|
// - every double quote (") is escaped by back slash (\);
|
||||||
// - finally, s is wrapped with double quotes (arg -> "arg"),
|
// - finally, s is wrapped with double quotes (arg -> "arg"),
|
||||||
// but only if there is space or tab inside s.
|
// but only if there is space or tab inside s.
|
||||||
func EscapeArg(s string) string {
|
func EscapeArg(s string) string {
|
||||||
if len(s) == 0 {
|
if len(s) == 0 {
|
||||||
return "\"\""
|
return "\"\""
|
||||||
|
|||||||
@@ -12,32 +12,34 @@ to standard output.
|
|||||||
The prototypes are marked by lines beginning with "//sys" and read
|
The prototypes are marked by lines beginning with "//sys" and read
|
||||||
like func declarations if //sys is replaced by func, but:
|
like func declarations if //sys is replaced by func, but:
|
||||||
|
|
||||||
* The parameter lists must give a name for each argument. This
|
- The parameter lists must give a name for each argument. This
|
||||||
includes return parameters.
|
includes return parameters.
|
||||||
|
|
||||||
* The parameter lists must give a type for each argument:
|
- The parameter lists must give a type for each argument:
|
||||||
the (x, y, z int) shorthand is not allowed.
|
the (x, y, z int) shorthand is not allowed.
|
||||||
|
|
||||||
* If the return parameter is an error number, it must be named err.
|
- If the return parameter is an error number, it must be named err.
|
||||||
|
|
||||||
* If go func name needs to be different from its winapi dll name,
|
- If go func name needs to be different from its winapi dll name,
|
||||||
the winapi name could be specified at the end, after "=" sign, like
|
the winapi name could be specified at the end, after "=" sign, like
|
||||||
//sys LoadLibrary(libname string) (handle uint32, err error) = LoadLibraryA
|
//sys LoadLibrary(libname string) (handle uint32, err error) = LoadLibraryA
|
||||||
|
|
||||||
* Each function that returns err needs to supply a condition, that
|
- Each function that returns err needs to supply a condition, that
|
||||||
return value of winapi will be tested against to detect failure.
|
return value of winapi will be tested against to detect failure.
|
||||||
This would set err to windows "last-error", otherwise it will be nil.
|
This would set err to windows "last-error", otherwise it will be nil.
|
||||||
The value can be provided at end of //sys declaration, like
|
The value can be provided at end of //sys declaration, like
|
||||||
//sys LoadLibrary(libname string) (handle uint32, err error) [failretval==-1] = LoadLibraryA
|
//sys LoadLibrary(libname string) (handle uint32, err error) [failretval==-1] = LoadLibraryA
|
||||||
and is [failretval==0] by default.
|
and is [failretval==0] by default.
|
||||||
|
|
||||||
* If the function name ends in a "?", then the function not existing is non-
|
- If the function name ends in a "?", then the function not existing is non-
|
||||||
fatal, and an error will be returned instead of panicking.
|
fatal, and an error will be returned instead of panicking.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
mkwinsyscall [flags] [path ...]
|
mkwinsyscall [flags] [path ...]
|
||||||
|
|
||||||
The flags are:
|
The flags are:
|
||||||
|
|
||||||
-output
|
-output
|
||||||
Specify output file name (outputs to console if blank).
|
Specify output file name (outputs to console if blank).
|
||||||
-trace
|
-trace
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
// log.Fatal(err)
|
// log.Fatal(err)
|
||||||
// }
|
// }
|
||||||
// fmt.Printf("Windows system root is %q\n", s)
|
// fmt.Printf("Windows system root is %q\n", s)
|
||||||
//
|
|
||||||
package registry
|
package registry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
// Package debug provides facilities to execute svc.Handler on console.
|
// Package debug provides facilities to execute svc.Handler on console.
|
||||||
//
|
|
||||||
package debug
|
package debug
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
// Package eventlog implements access to Windows event log.
|
// Package eventlog implements access to Windows event log.
|
||||||
//
|
|
||||||
package eventlog
|
package eventlog
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
// stop / start / pause / continue any service, and how to
|
// stop / start / pause / continue any service, and how to
|
||||||
// write to event log. It also shows how to use debug
|
// write to event log. It also shows how to use debug
|
||||||
// facilities available in debug package.
|
// facilities available in debug package.
|
||||||
//
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
// It can be used to install and remove them. It can also start,
|
// It can be used to install and remove them. It can also start,
|
||||||
// stop and pause them. The package can query / change current
|
// stop and pause them. The package can query / change current
|
||||||
// service state and config parameters.
|
// service state and config parameters.
|
||||||
//
|
|
||||||
package mgr
|
package mgr
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
// Package svc provides everything required to build Windows service.
|
// Package svc provides everything required to build Windows service.
|
||||||
//
|
|
||||||
package svc
|
package svc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
Reference in New Issue
Block a user