code
stringlengths
11
335k
docstring
stringlengths
20
11.8k
func_name
stringlengths
1
100
language
stringclasses
1 value
repo
stringclasses
245 values
path
stringlengths
4
144
url
stringlengths
43
214
license
stringclasses
4 values
func Minor(dev uint64) uint32 { return uint32(dev & 0xffff) }
Minor returns the minor component of a Linux device number.
Minor
go
flynn/flynn
vendor/golang.org/x/sys/unix/dev_aix_ppc.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/dev_aix_ppc.go
BSD-3-Clause
func Mkdev(major, minor uint32) uint64 { return uint64(((major) << 16) | (minor)) }
Mkdev returns a Linux device number generated from the given major and minor components.
Mkdev
go
flynn/flynn
vendor/golang.org/x/sys/unix/dev_aix_ppc.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/dev_aix_ppc.go
BSD-3-Clause
func PtraceGetRegs386(pid int, regsout *PtraceRegs386) error { return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) }
PtraceGetRegs386 fetches the registers used by 386 binaries.
PtraceGetRegs386
go
flynn/flynn
vendor/golang.org/x/sys/unix/zptrace386_linux.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/zptrace386_linux.go
BSD-3-Clause
func PtraceSetRegs386(pid int, regs *PtraceRegs386) error { return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) }
PtraceSetRegs386 sets the registers used by 386 binaries.
PtraceSetRegs386
go
flynn/flynn
vendor/golang.org/x/sys/unix/zptrace386_linux.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/zptrace386_linux.go
BSD-3-Clause
func PtraceGetRegsAmd64(pid int, regsout *PtraceRegsAmd64) error { return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) }
PtraceGetRegsAmd64 fetches the registers used by amd64 binaries.
PtraceGetRegsAmd64
go
flynn/flynn
vendor/golang.org/x/sys/unix/zptrace386_linux.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/zptrace386_linux.go
BSD-3-Clause
func PtraceSetRegsAmd64(pid int, regs *PtraceRegsAmd64) error { return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) }
PtraceSetRegsAmd64 sets the registers used by amd64 binaries.
PtraceSetRegsAmd64
go
flynn/flynn
vendor/golang.org/x/sys/unix/zptrace386_linux.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/zptrace386_linux.go
BSD-3-Clause
func nametomib(name string) (mib []_C_int, err error) { const siz = unsafe.Sizeof(mib[0]) // NOTE(rsc): It seems strange to set the buffer to have // size CTL_MAXNAME+2 but use only CTL_MAXNAME // as the size. I don't know why the +2 is here, but the // kernel uses +2 for its own implementation of this function. // I am scared that if we don't include the +2 here, the kernel // will silently write 2 words farther than we specify // and we'll get memory corruption. var buf [CTL_MAXNAME + 2]_C_int n := uintptr(CTL_MAXNAME) * siz p := (*byte)(unsafe.Pointer(&buf[0])) bytes, err := ByteSliceFromString(name) if err != nil { return nil, err } // Magic sysctl: "setting" 0.3 to a string name // lets you read back the array of integers form. if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil { return nil, err } return buf[0 : n/siz], nil }
Translate "kern.hostname" to []_C_int{0,1,2,3}.
nametomib
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_darwin.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_darwin.go
BSD-3-Clause
func PtraceAttach(pid int) (err error) { return ptrace(PT_ATTACH, pid, 0, 0) }
sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
PtraceAttach
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_darwin.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_darwin.go
BSD-3-Clause
func IoctlSetInt(fd int, req uint, value int) error { return ioctl(fd, req, uintptr(value)) }
IoctlSetInt performs an ioctl operation which sets an integer value on fd, using the specified request number.
IoctlSetInt
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_darwin.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_darwin.go
BSD-3-Clause
func IoctlGetInt(fd int, req uint) (int, error) { var value int err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) return value, err }
IoctlGetInt performs an ioctl operation which gets an integer value from fd, using the specified request number.
IoctlGetInt
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_darwin.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_darwin.go
BSD-3-Clause
func fixStatTimFields(stat *Stat_t) { stat.Atim.Nsec >>= 32 stat.Mtim.Nsec >>= 32 stat.Ctim.Nsec >>= 32 }
In order to only have Timespec structure, type of Stat_t's fields Atim, Mtim and Ctim is changed from StTimespec to Timespec during ztypes generation. On ppc64, Timespec.Nsec is an int64 while StTimespec.Nsec is an int32, so the fields' value must be modified.
fixStatTimFields
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go
BSD-3-Clause
func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) { mmap_args := [6]uintptr{addr, length, uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset)} r0, _, e1 := Syscall(SYS_MMAP, uintptr(unsafe.Pointer(&mmap_args[0])), 0, 0) xaddr = uintptr(r0) if e1 != 0 { err = errnoErr(e1) } return }
Linux on s390x uses the old mmap interface, which requires arguments to be passed in a struct. mmap2 also requires arguments to be passed in a struct; it is currently not exposed in <asm/unistd.h>.
mmap
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_linux_s390x.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go
BSD-3-Clause
func Major(dev uint64) uint32 { return uint32((dev >> 8) & 0xff) }
Major returns the major component of a FreeBSD device number.
Major
go
flynn/flynn
vendor/golang.org/x/sys/unix/dev_freebsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/dev_freebsd.go
BSD-3-Clause
func Minor(dev uint64) uint32 { return uint32(dev & 0xffff00ff) }
Minor returns the minor component of a FreeBSD device number.
Minor
go
flynn/flynn
vendor/golang.org/x/sys/unix/dev_freebsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/dev_freebsd.go
BSD-3-Clause
func Mkdev(major, minor uint32) uint64 { return (uint64(major) << 8) | uint64(minor) }
Mkdev returns a FreeBSD device number generated from the given major and minor components.
Mkdev
go
flynn/flynn
vendor/golang.org/x/sys/unix/dev_freebsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/dev_freebsd.go
BSD-3-Clause
func IoctlSetWinsize(fd int, req uint, value *Winsize) error { // TODO: if we get the chance, remove the req parameter and // hardcode TIOCSWINSZ. err := ioctlSetWinsize(fd, req, value) runtime.KeepAlive(value) return err }
IoctlSetWinsize performs an ioctl on fd with a *Winsize argument. To change fd's window size, the req argument should be TIOCSWINSZ.
IoctlSetWinsize
go
flynn/flynn
vendor/golang.org/x/sys/unix/ioctl.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/ioctl.go
BSD-3-Clause
func IoctlSetTermios(fd int, req uint, value *Termios) error { // TODO: if we get the chance, remove the req parameter. err := ioctlSetTermios(fd, req, value) runtime.KeepAlive(value) return err }
IoctlSetTermios performs an ioctl on fd with a *Termios. The req value will usually be TCSETA or TIOCSETA.
IoctlSetTermios
go
flynn/flynn
vendor/golang.org/x/sys/unix/ioctl.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/ioctl.go
BSD-3-Clause
func Gettimeofday(tv *Timeval) (err error) { // The tv passed to gettimeofday must be non-nil // but is otherwise unused. The answers come back // in the two registers. sec, usec, err := gettimeofday(tv) tv.Sec = int32(sec) tv.Usec = int32(usec) return err }
sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error)
Gettimeofday
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_darwin_arm.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_darwin_arm.go
BSD-3-Clause
func ReadDirent(fd int, buf []byte) (n int, err error) { return Getdents(fd, buf) }
ReadDirent reads directory entries from fd and writes them into buf.
ReadDirent
go
flynn/flynn
vendor/golang.org/x/sys/unix/readdirent_getdents.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/readdirent_getdents.go
BSD-3-Clause
func Major(dev uint64) uint32 { return uint32((dev >> 24) & 0xff) }
Major returns the major component of a Darwin device number.
Major
go
flynn/flynn
vendor/golang.org/x/sys/unix/dev_darwin.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/dev_darwin.go
BSD-3-Clause
func Minor(dev uint64) uint32 { return uint32(dev & 0xffffff) }
Minor returns the minor component of a Darwin device number.
Minor
go
flynn/flynn
vendor/golang.org/x/sys/unix/dev_darwin.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/dev_darwin.go
BSD-3-Clause
func Mkdev(major, minor uint32) uint64 { return (uint64(major) << 24) | uint64(minor) }
Mkdev returns a Darwin device number generated from the given major and minor components.
Mkdev
go
flynn/flynn
vendor/golang.org/x/sys/unix/dev_darwin.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/dev_darwin.go
BSD-3-Clause
func FcntlInt(fd uintptr, cmd, arg int) (int, error) { valptr, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(arg)) var err error if errno != 0 { err = errno } return int(valptr), err }
FcntlInt performs a fcntl syscall on fd with the provided command and argument.
FcntlInt
go
flynn/flynn
vendor/golang.org/x/sys/unix/fcntl.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/fcntl.go
BSD-3-Clause
func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) if errno == 0 { return nil } return errno }
FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
FcntlFlock
go
flynn/flynn
vendor/golang.org/x/sys/unix/fcntl.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/fcntl.go
BSD-3-Clause
func Major(dev uint64) uint32 { return uint32((dev & 0x0000ff00) >> 8) }
Major returns the major component of an OpenBSD device number.
Major
go
flynn/flynn
vendor/golang.org/x/sys/unix/dev_openbsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/dev_openbsd.go
BSD-3-Clause
func Minor(dev uint64) uint32 { minor := uint32((dev & 0x000000ff) >> 0) minor |= uint32((dev & 0xffff0000) >> 8) return minor }
Minor returns the minor component of an OpenBSD device number.
Minor
go
flynn/flynn
vendor/golang.org/x/sys/unix/dev_openbsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/dev_openbsd.go
BSD-3-Clause
func Mkdev(major, minor uint32) uint64 { dev := (uint64(major) << 8) & 0x0000ff00 dev |= (uint64(minor) << 8) & 0xffff0000 dev |= (uint64(minor) << 0) & 0x000000ff return dev }
Mkdev returns an OpenBSD device number generated from the given major and minor components.
Mkdev
go
flynn/flynn
vendor/golang.org/x/sys/unix/dev_openbsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/dev_openbsd.go
BSD-3-Clause
func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { newoffset, errno := seek(fd, offset, whence) if errno != 0 { return 0, errno } return newoffset, nil }
Underlying system call writes to newoffset via pointer. Implemented in assembly to avoid allocation.
seek
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_linux_arm.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_linux_arm.go
BSD-3-Clause
func Unveil(path string, flags string) error { pathPtr, err := syscall.BytePtrFromString(path) if err != nil { return err } flagsPtr, err := syscall.BytePtrFromString(flags) if err != nil { return err } _, _, e := syscall.Syscall(SYS_UNVEIL, uintptr(unsafe.Pointer(pathPtr)), uintptr(unsafe.Pointer(flagsPtr)), 0) if e != 0 { return e } return nil }
Unveil implements the unveil syscall. For more information see unveil(2). Note that the special case of blocking further unveil calls is handled by UnveilBlock.
Unveil
go
flynn/flynn
vendor/golang.org/x/sys/unix/unveil_openbsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/unveil_openbsd.go
BSD-3-Clause
func UnveilBlock() error { // Both pointers must be nil. var pathUnsafe, flagsUnsafe unsafe.Pointer _, _, e := syscall.Syscall(SYS_UNVEIL, uintptr(pathUnsafe), uintptr(flagsUnsafe), 0) if e != 0 { return e } return nil }
UnveilBlock blocks future unveil calls. For more information see unveil(2).
UnveilBlock
go
flynn/flynn
vendor/golang.org/x/sys/unix/unveil_openbsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/unveil_openbsd.go
BSD-3-Clause
func FcntlInt(fd uintptr, cmd, arg int) (int, error) { return fcntl(int(fd), cmd, arg) }
FcntlInt performs a fcntl syscall on fd with the provided command and argument.
FcntlInt
go
flynn/flynn
vendor/golang.org/x/sys/unix/fcntl_darwin.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/fcntl_darwin.go
BSD-3-Clause
func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { _, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(lk)))) return err }
FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
FcntlFlock
go
flynn/flynn
vendor/golang.org/x/sys/unix/fcntl_darwin.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/fcntl_darwin.go
BSD-3-Clause
func PtraceGetRegsArm(pid int, regsout *PtraceRegsArm) error { return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) }
PtraceGetRegsArm fetches the registers used by arm binaries.
PtraceGetRegsArm
go
flynn/flynn
vendor/golang.org/x/sys/unix/zptracearm_linux.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/zptracearm_linux.go
BSD-3-Clause
func PtraceSetRegsArm(pid int, regs *PtraceRegsArm) error { return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) }
PtraceSetRegsArm sets the registers used by arm binaries.
PtraceSetRegsArm
go
flynn/flynn
vendor/golang.org/x/sys/unix/zptracearm_linux.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/zptracearm_linux.go
BSD-3-Clause
func PtraceGetRegsArm64(pid int, regsout *PtraceRegsArm64) error { return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) }
PtraceGetRegsArm64 fetches the registers used by arm64 binaries.
PtraceGetRegsArm64
go
flynn/flynn
vendor/golang.org/x/sys/unix/zptracearm_linux.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/zptracearm_linux.go
BSD-3-Clause
func PtraceSetRegsArm64(pid int, regs *PtraceRegsArm64) error { return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) }
PtraceSetRegsArm64 sets the registers used by arm64 binaries.
PtraceSetRegsArm64
go
flynn/flynn
vendor/golang.org/x/sys/unix/zptracearm_linux.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/zptracearm_linux.go
BSD-3-Clause
func UnixCredentials(ucred *Ucred) []byte { b := make([]byte, CmsgSpace(SizeofUcred)) h := (*Cmsghdr)(unsafe.Pointer(&b[0])) h.Level = SOL_SOCKET h.Type = SCM_CREDENTIALS h.SetLen(CmsgLen(SizeofUcred)) *((*Ucred)(cmsgData(h))) = *ucred return b }
UnixCredentials encodes credentials into a socket control message for sending to another process. This can be used for authentication.
UnixCredentials
go
flynn/flynn
vendor/golang.org/x/sys/unix/sockcmsg_linux.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/sockcmsg_linux.go
BSD-3-Clause
func ParseUnixCredentials(m *SocketControlMessage) (*Ucred, error) { if m.Header.Level != SOL_SOCKET { return nil, EINVAL } if m.Header.Type != SCM_CREDENTIALS { return nil, EINVAL } ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0])) return &ucred, nil }
ParseUnixCredentials decodes a socket control message that contains credentials in a Ucred structure. To receive such a message, the SO_PASSCRED option must be enabled on the socket.
ParseUnixCredentials
go
flynn/flynn
vendor/golang.org/x/sys/unix/sockcmsg_linux.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/sockcmsg_linux.go
BSD-3-Clause
func Pipe(p []int) (err error) { if len(p) != 2 { return EINVAL } p[0], p[1], err = pipe() return }
sysnb pipe() (fd1 int, fd2 int, err error)
Pipe
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_netbsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_netbsd.go
BSD-3-Clause
func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { n, err = Getdents(fd, buf) if err != nil || basep == nil { return } var off int64 off, err = Seek(fd, 0, 1 /* SEEK_CUR */) if err != nil { *basep = ^uintptr(0) return } *basep = uintptr(off) if unsafe.Sizeof(*basep) == 8 { return } if off>>32 != 0 { // We can't stuff the offset back into a uintptr, so any // future calls would be suspect. Generate an error. // EIO is allowed by getdirentries. err = EIO } return }
sys Getdents(fd int, buf []byte) (n int, err error)
Getdirentries
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_netbsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_netbsd.go
BSD-3-Clause
func IoctlSetInt(fd int, req uint, value int) error { return ioctl(fd, req, uintptr(value)) }
IoctlSetInt performs an ioctl operation which sets an integer value on fd, using the specified request number.
IoctlSetInt
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_netbsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_netbsd.go
BSD-3-Clause
func IoctlGetInt(fd int, req uint) (int, error) { var value int err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) return value, err }
IoctlGetInt performs an ioctl operation which gets an integer value from fd, using the specified request number.
IoctlGetInt
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_netbsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_netbsd.go
BSD-3-Clause
func CapRightsSet(rights *CapRights, setrights []uint64) error { // This is essentially a copy of cap_rights_vset() if capver(rights) != CAP_RIGHTS_VERSION_00 { return fmt.Errorf("bad rights version %d", capver(rights)) } n := caparsize(rights) if n < capArSizeMin || n > capArSizeMax { return errors.New("bad rights size") } for _, right := range setrights { if caprver(right) != CAP_RIGHTS_VERSION_00 { return errors.New("bad right version") } i, err := rightToIndex(right) if err != nil { return err } if i >= n { return errors.New("index overflow") } if capidxbit(rights.Rights[i]) != capidxbit(right) { return errors.New("index mismatch") } rights.Rights[i] |= right if capidxbit(rights.Rights[i]) != capidxbit(right) { return errors.New("index mismatch (after assign)") } } return nil }
CapRightsSet sets the permissions in setrights in rights.
CapRightsSet
go
flynn/flynn
vendor/golang.org/x/sys/unix/cap_freebsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/cap_freebsd.go
BSD-3-Clause
func CapRightsClear(rights *CapRights, clearrights []uint64) error { // This is essentially a copy of cap_rights_vclear() if capver(rights) != CAP_RIGHTS_VERSION_00 { return fmt.Errorf("bad rights version %d", capver(rights)) } n := caparsize(rights) if n < capArSizeMin || n > capArSizeMax { return errors.New("bad rights size") } for _, right := range clearrights { if caprver(right) != CAP_RIGHTS_VERSION_00 { return errors.New("bad right version") } i, err := rightToIndex(right) if err != nil { return err } if i >= n { return errors.New("index overflow") } if capidxbit(rights.Rights[i]) != capidxbit(right) { return errors.New("index mismatch") } rights.Rights[i] &= ^(right & 0x01FFFFFFFFFFFFFF) if capidxbit(rights.Rights[i]) != capidxbit(right) { return errors.New("index mismatch (after assign)") } } return nil }
CapRightsClear clears the permissions in clearrights from rights.
CapRightsClear
go
flynn/flynn
vendor/golang.org/x/sys/unix/cap_freebsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/cap_freebsd.go
BSD-3-Clause
func CapRightsIsSet(rights *CapRights, setrights []uint64) (bool, error) { // This is essentially a copy of cap_rights_is_vset() if capver(rights) != CAP_RIGHTS_VERSION_00 { return false, fmt.Errorf("bad rights version %d", capver(rights)) } n := caparsize(rights) if n < capArSizeMin || n > capArSizeMax { return false, errors.New("bad rights size") } for _, right := range setrights { if caprver(right) != CAP_RIGHTS_VERSION_00 { return false, errors.New("bad right version") } i, err := rightToIndex(right) if err != nil { return false, err } if i >= n { return false, errors.New("index overflow") } if capidxbit(rights.Rights[i]) != capidxbit(right) { return false, errors.New("index mismatch") } if (rights.Rights[i] & right) != right { return false, nil } } return true, nil }
CapRightsIsSet checks whether all the permissions in setrights are present in rights.
CapRightsIsSet
go
flynn/flynn
vendor/golang.org/x/sys/unix/cap_freebsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/cap_freebsd.go
BSD-3-Clause
func CapRightsInit(rights []uint64) (*CapRights, error) { var r CapRights r.Rights[0] = (capRightsGoVersion << 62) | capright(0, 0) r.Rights[1] = capright(1, 0) err := CapRightsSet(&r, rights) if err != nil { return nil, err } return &r, nil }
CapRightsInit returns a pointer to an initialised CapRights structure filled with rights. See man cap_rights_init(3) and rights(4).
CapRightsInit
go
flynn/flynn
vendor/golang.org/x/sys/unix/cap_freebsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/cap_freebsd.go
BSD-3-Clause
func CapRightsLimit(fd uintptr, rights *CapRights) error { return capRightsLimit(int(fd), rights) }
CapRightsLimit reduces the operations permitted on fd to at most those contained in rights. The capability rights on fd can never be increased by CapRightsLimit. See man cap_rights_limit(2) and rights(4).
CapRightsLimit
go
flynn/flynn
vendor/golang.org/x/sys/unix/cap_freebsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/cap_freebsd.go
BSD-3-Clause
func CapRightsGet(fd uintptr) (*CapRights, error) { r, err := CapRightsInit(nil) if err != nil { return nil, err } err = capRightsGet(capRightsGoVersion, int(fd), r) if err != nil { return nil, err } return r, nil }
CapRightsGet returns a CapRights structure containing the operations permitted on fd. See man cap_rights_get(3) and rights(4).
CapRightsGet
go
flynn/flynn
vendor/golang.org/x/sys/unix/cap_freebsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/cap_freebsd.go
BSD-3-Clause
func nametomib(name string) (mib []_C_int, err error) { const siz = unsafe.Sizeof(mib[0]) // NOTE(rsc): It seems strange to set the buffer to have // size CTL_MAXNAME+2 but use only CTL_MAXNAME // as the size. I don't know why the +2 is here, but the // kernel uses +2 for its own implementation of this function. // I am scared that if we don't include the +2 here, the kernel // will silently write 2 words farther than we specify // and we'll get memory corruption. var buf [CTL_MAXNAME + 2]_C_int n := uintptr(CTL_MAXNAME) * siz p := (*byte)(unsafe.Pointer(&buf[0])) bytes, err := ByteSliceFromString(name) if err != nil { return nil, err } // Magic sysctl: "setting" 0.3 to a string name // lets you read back the array of integers form. if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil { return nil, err } return buf[0 : n/siz], nil }
Translate "kern.hostname" to []_C_int{0,1,2,3}.
nametomib
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_freebsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_freebsd.go
BSD-3-Clause
func IoctlSetInt(fd int, req uint, value int) error { return ioctl(fd, req, uintptr(value)) }
IoctlSetInt performs an ioctl operation which sets an integer value on fd, using the specified request number.
IoctlSetInt
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_freebsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_freebsd.go
BSD-3-Clause
func IoctlGetInt(fd int, req uint) (int, error) { var value int err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) return value, err }
IoctlGetInt performs an ioctl operation which gets an integer value from fd, using the specified request number.
IoctlGetInt
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_freebsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_freebsd.go
BSD-3-Clause
func roundup(x, y int) int { return ((x + y - 1) / y) * y }
round x to the nearest multiple of y, larger or equal to x. from /usr/include/sys/param.h Macros for counting and rounding. #define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
roundup
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_freebsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_freebsd.go
BSD-3-Clause
func Gettimeofday(tv *Timeval) (err error) { // The tv passed to gettimeofday must be non-nil // but is otherwise unused. The answers come back // in the two registers. sec, usec, err := gettimeofday(tv) tv.Sec = sec tv.Usec = usec return err }
sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error)
Gettimeofday
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go
BSD-3-Clause
func GetsockoptString(fd, level, opt int) (string, error) { buf := make([]byte, 256) vallen := _Socklen(len(buf)) err := getsockopt(fd, level, opt, unsafe.Pointer(&buf[0]), &vallen) if err != nil { return "", err } return string(buf[:vallen-1]), nil }
GetsockoptString returns the string value of the socket option opt for the socket associated with fd at the given socket level.
GetsockoptString
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_bsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_bsd.go
BSD-3-Clause
func sysctlmib(name string, args ...int) ([]_C_int, error) { // Translate name to mib number. mib, err := nametomib(name) if err != nil { return nil, err } for _, a := range args { mib = append(mib, _C_int(a)) } return mib, nil }
sysctlmib translates name to mib number and appends any additional args.
sysctlmib
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_bsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_bsd.go
BSD-3-Clause
func SchedGetaffinity(pid int, set *CPUSet) error { return schedAffinity(SYS_SCHED_GETAFFINITY, pid, set) }
SchedGetaffinity gets the CPU affinity mask of the thread specified by pid. If pid is 0 the calling thread is used.
SchedGetaffinity
go
flynn/flynn
vendor/golang.org/x/sys/unix/affinity_linux.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/affinity_linux.go
BSD-3-Clause
func SchedSetaffinity(pid int, set *CPUSet) error { return schedAffinity(SYS_SCHED_SETAFFINITY, pid, set) }
SchedSetaffinity sets the CPU affinity mask of the thread specified by pid. If pid is 0 the calling thread is used.
SchedSetaffinity
go
flynn/flynn
vendor/golang.org/x/sys/unix/affinity_linux.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/affinity_linux.go
BSD-3-Clause
func (s *CPUSet) Zero() { for i := range s { s[i] = 0 } }
Zero clears the set s, so that it contains no CPUs.
Zero
go
flynn/flynn
vendor/golang.org/x/sys/unix/affinity_linux.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/affinity_linux.go
BSD-3-Clause
func (s *CPUSet) Set(cpu int) { i := cpuBitsIndex(cpu) if i < len(s) { s[i] |= cpuBitsMask(cpu) } }
Set adds cpu to the set s.
Set
go
flynn/flynn
vendor/golang.org/x/sys/unix/affinity_linux.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/affinity_linux.go
BSD-3-Clause
func (s *CPUSet) Clear(cpu int) { i := cpuBitsIndex(cpu) if i < len(s) { s[i] &^= cpuBitsMask(cpu) } }
Clear removes cpu from the set s.
Clear
go
flynn/flynn
vendor/golang.org/x/sys/unix/affinity_linux.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/affinity_linux.go
BSD-3-Clause
func (s *CPUSet) IsSet(cpu int) bool { i := cpuBitsIndex(cpu) if i < len(s) { return s[i]&cpuBitsMask(cpu) != 0 } return false }
IsSet reports whether cpu is in the set s.
IsSet
go
flynn/flynn
vendor/golang.org/x/sys/unix/affinity_linux.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/affinity_linux.go
BSD-3-Clause
func (s *CPUSet) Count() int { c := 0 for _, b := range s { c += onesCount64(uint64(b)) } return c }
Count returns the number of CPUs in the set s.
Count
go
flynn/flynn
vendor/golang.org/x/sys/unix/affinity_linux.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/affinity_linux.go
BSD-3-Clause
func onesCount64(x uint64) int { const m0 = 0x5555555555555555 // 01010101 ... const m1 = 0x3333333333333333 // 00110011 ... const m2 = 0x0f0f0f0f0f0f0f0f // 00001111 ... // Unused in this function, but definitions preserved for // documentation purposes: // // const m3 = 0x00ff00ff00ff00ff // etc. // const m4 = 0x0000ffff0000ffff // // Implementation: Parallel summing of adjacent bits. // See "Hacker's Delight", Chap. 5: Counting Bits. // The following pattern shows the general approach: // // x = x>>1&(m0&m) + x&(m0&m) // x = x>>2&(m1&m) + x&(m1&m) // x = x>>4&(m2&m) + x&(m2&m) // x = x>>8&(m3&m) + x&(m3&m) // x = x>>16&(m4&m) + x&(m4&m) // x = x>>32&(m5&m) + x&(m5&m) // return int(x) // // Masking (& operations) can be left away when there's no // danger that a field's sum will carry over into the next // field: Since the result cannot be > 64, 8 bits is enough // and we can ignore the masks for the shifts by 8 and up. // Per "Hacker's Delight", the first line can be simplified // more, but it saves at best one instruction, so we leave // it alone for clarity. const m = 1<<64 - 1 x = x>>1&(m0&m) + x&(m0&m) x = x>>2&(m1&m) + x&(m1&m) x = (x>>4 + x) & (m2 & m) x += x >> 8 x += x >> 16 x += x >> 32 return int(x) & (1<<7 - 1) }
onesCount64 is a copy of Go 1.9's math/bits.OnesCount64. Once this package can require Go 1.9, we can delete this and update the caller to use bits.OnesCount64.
onesCount64
go
flynn/flynn
vendor/golang.org/x/sys/unix/affinity_linux.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/affinity_linux.go
BSD-3-Clause
func cmsgAlignOf(salen int) int { salign := SizeofPtr switch runtime.GOOS { case "aix": // There is no alignment on AIX. salign = 1 case "darwin", "dragonfly", "solaris", "illumos": // NOTE: It seems like 64-bit Darwin, DragonFly BSD, // illumos, and Solaris kernels still require 32-bit // aligned access to network subsystem. if SizeofPtr == 8 { salign = 4 } case "netbsd", "openbsd": // NetBSD and OpenBSD armv7 require 64-bit alignment. if runtime.GOARCH == "arm" { salign = 8 } } return (salen + salign - 1) & ^(salign - 1) }
Round the length of a raw sockaddr up to align it properly.
cmsgAlignOf
go
flynn/flynn
vendor/golang.org/x/sys/unix/sockcmsg_unix.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/sockcmsg_unix.go
BSD-3-Clause
func CmsgLen(datalen int) int { return cmsgAlignOf(SizeofCmsghdr) + datalen }
CmsgLen returns the value to store in the Len field of the Cmsghdr structure, taking into account any necessary alignment.
CmsgLen
go
flynn/flynn
vendor/golang.org/x/sys/unix/sockcmsg_unix.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/sockcmsg_unix.go
BSD-3-Clause
func CmsgSpace(datalen int) int { return cmsgAlignOf(SizeofCmsghdr) + cmsgAlignOf(datalen) }
CmsgSpace returns the number of bytes an ancillary element with payload of the passed data length occupies.
CmsgSpace
go
flynn/flynn
vendor/golang.org/x/sys/unix/sockcmsg_unix.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/sockcmsg_unix.go
BSD-3-Clause
func ParseSocketControlMessage(b []byte) ([]SocketControlMessage, error) { var msgs []SocketControlMessage i := 0 for i+CmsgLen(0) <= len(b) { h, dbuf, err := socketControlMessageHeaderAndData(b[i:]) if err != nil { return nil, err } m := SocketControlMessage{Header: *h, Data: dbuf} msgs = append(msgs, m) i += cmsgAlignOf(int(h.Len)) } return msgs, nil }
ParseSocketControlMessage parses b as an array of socket control messages.
ParseSocketControlMessage
go
flynn/flynn
vendor/golang.org/x/sys/unix/sockcmsg_unix.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/sockcmsg_unix.go
BSD-3-Clause
func UnixRights(fds ...int) []byte { datalen := len(fds) * 4 b := make([]byte, CmsgSpace(datalen)) h := (*Cmsghdr)(unsafe.Pointer(&b[0])) h.Level = SOL_SOCKET h.Type = SCM_RIGHTS h.SetLen(CmsgLen(datalen)) data := cmsgData(h) for _, fd := range fds { *(*int32)(data) = int32(fd) data = unsafe.Pointer(uintptr(data) + 4) } return b }
UnixRights encodes a set of open file descriptors into a socket control message for sending to another process.
UnixRights
go
flynn/flynn
vendor/golang.org/x/sys/unix/sockcmsg_unix.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/sockcmsg_unix.go
BSD-3-Clause
func ParseUnixRights(m *SocketControlMessage) ([]int, error) { if m.Header.Level != SOL_SOCKET { return nil, EINVAL } if m.Header.Type != SCM_RIGHTS { return nil, EINVAL } fds := make([]int, len(m.Data)>>2) for i, j := 0, 0; i < len(m.Data); i += 4 { fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i]))) j++ } return fds, nil }
ParseUnixRights decodes a socket control message that contains an integer array of open file descriptors from another process.
ParseUnixRights
go
flynn/flynn
vendor/golang.org/x/sys/unix/sockcmsg_unix.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/sockcmsg_unix.go
BSD-3-Clause
func Pipe(p []int) (err error) { if len(p) != 2 { return EINVAL } var pp [2]_C_int err = pipe(&pp) p[0] = int(pp[0]) p[1] = int(pp[1]) return }
sysnb pipe(p *[2]_C_int) (err error)
Pipe
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_openbsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_openbsd.go
BSD-3-Clause
func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { n, err = Getdents(fd, buf) if err != nil || basep == nil { return } var off int64 off, err = Seek(fd, 0, 1 /* SEEK_CUR */) if err != nil { *basep = ^uintptr(0) return } *basep = uintptr(off) if unsafe.Sizeof(*basep) == 8 { return } if off>>32 != 0 { // We can't stuff the offset back into a uintptr, so any // future calls would be suspect. Generate an error. // EIO was allowed by getdirentries. err = EIO } return }
sys Getdents(fd int, buf []byte) (n int, err error)
Getdirentries
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_openbsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_openbsd.go
BSD-3-Clause
func IoctlSetInt(fd int, req uint, value int) error { return ioctl(fd, req, uintptr(value)) }
IoctlSetInt performs an ioctl operation which sets an integer value on fd, using the specified request number.
IoctlSetInt
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_openbsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_openbsd.go
BSD-3-Clause
func IoctlGetInt(fd int, req uint) (int, error) { var value int err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) return value, err }
IoctlGetInt performs an ioctl operation which gets an integer value from fd, using the specified request number.
IoctlGetInt
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_openbsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_openbsd.go
BSD-3-Clause
func Major(dev uint64) uint32 { return uint32((dev & 0x3fffffff00000000) >> 32) }
Major returns the major component of a Linux device number.
Major
go
flynn/flynn
vendor/golang.org/x/sys/unix/dev_aix_ppc64.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/dev_aix_ppc64.go
BSD-3-Clause
func Minor(dev uint64) uint32 { return uint32((dev & 0x00000000ffffffff) >> 0) }
Minor returns the minor component of a Linux device number.
Minor
go
flynn/flynn
vendor/golang.org/x/sys/unix/dev_aix_ppc64.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/dev_aix_ppc64.go
BSD-3-Clause
func Mkdev(major, minor uint32) uint64 { var DEVNO64 uint64 DEVNO64 = 0x8000000000000000 return ((uint64(major) << 32) | (uint64(minor) & 0x00000000FFFFFFFF) | DEVNO64) }
Mkdev returns a Linux device number generated from the given major and minor components.
Mkdev
go
flynn/flynn
vendor/golang.org/x/sys/unix/dev_aix_ppc64.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/dev_aix_ppc64.go
BSD-3-Clause
func Utimes(path string, tv []Timeval) error { if len(tv) != 2 { return EINVAL } return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) }
sys utimes(path string, times *[2]Timeval) (err error)
Utimes
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_aix.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_aix.go
BSD-3-Clause
func UtimesNano(path string, ts []Timespec) error { if len(ts) != 2 { return EINVAL } return utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) }
sys utimensat(dirfd int, path string, times *[2]Timespec, flag int) (err error)
UtimesNano
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_aix.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_aix.go
BSD-3-Clause
func Getdents(fd int, buf []byte) (n int, err error) { return getdirent(fd, buf) }
sys getdirent(fd int, buf []byte) (n int, err error)
Getdents
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_aix.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_aix.go
BSD-3-Clause
func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) { var status _C_int var r Pid_t err = ERESTART // AIX wait4 may return with ERESTART errno, while the processus is still // active. for err == ERESTART { r, err = wait4(Pid_t(pid), &status, options, rusage) } wpid = int(r) if wstatus != nil { *wstatus = WaitStatus(status) } return }
sys wait4(pid Pid_t, status *_C_int, options int, rusage *Rusage) (wpid Pid_t, err error)
Wait4
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_aix.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_aix.go
BSD-3-Clause
func IoctlSetInt(fd int, req uint, value int) error { return ioctl(fd, req, uintptr(value)) }
IoctlSetInt performs an ioctl operation which sets an integer value on fd, using the specified request number.
IoctlSetInt
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_aix.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_aix.go
BSD-3-Clause
func IoctlGetInt(fd int, req uint) (int, error) { var value int err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) return value, err }
IoctlGetInt performs an ioctl operation which gets an integer value from fd, using the specified request number.
IoctlGetInt
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_aix.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_aix.go
BSD-3-Clause
func Unmount(target string, flags int) (err error) { if flags != 0 { // AIX doesn't have any flags for umount. return ENOSYS } return umount(target) }
sys umount(target string) (err error)
Unmount
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_aix.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_aix.go
BSD-3-Clause
func Gettimeofday(tv *Timeval) (err error) { // The tv passed to gettimeofday must be non-nil // but is otherwise unused. The answers come back // in the two registers. sec, usec, err := gettimeofday(tv) tv.Sec = int32(sec) tv.Usec = int32(usec) return err }
sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error)
Gettimeofday
go
flynn/flynn
vendor/golang.org/x/sys/unix/syscall_darwin_386.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_darwin_386.go
BSD-3-Clause
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
TimespecToNsec converts a Timespec value into a number of nanoseconds since the Unix epoch.
TimespecToNsec
go
flynn/flynn
vendor/golang.org/x/sys/unix/timestruct.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/timestruct.go
BSD-3-Clause
func NsecToTimespec(nsec int64) Timespec { sec := nsec / 1e9 nsec = nsec % 1e9 if nsec < 0 { nsec += 1e9 sec-- } return setTimespec(sec, nsec) }
NsecToTimespec takes a number of nanoseconds since the Unix epoch and returns the corresponding Timespec value.
NsecToTimespec
go
flynn/flynn
vendor/golang.org/x/sys/unix/timestruct.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/timestruct.go
BSD-3-Clause
func TimeToTimespec(t time.Time) (Timespec, error) { sec := t.Unix() nsec := int64(t.Nanosecond()) ts := setTimespec(sec, nsec) // Currently all targets have either int32 or int64 for Timespec.Sec. // If there were a new target with floating point type for it, we have // to consider the rounding error. if int64(ts.Sec) != sec { return Timespec{}, ERANGE } return ts, nil }
TimeToTimespec converts t into a Timespec. On some 32-bit systems the range of valid Timespec values are smaller than that of time.Time values. So if t is out of the valid range of Timespec, it returns a zero Timespec and ERANGE.
TimeToTimespec
go
flynn/flynn
vendor/golang.org/x/sys/unix/timestruct.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/timestruct.go
BSD-3-Clause
func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
TimevalToNsec converts a Timeval value into a number of nanoseconds since the Unix epoch.
TimevalToNsec
go
flynn/flynn
vendor/golang.org/x/sys/unix/timestruct.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/timestruct.go
BSD-3-Clause
func NsecToTimeval(nsec int64) Timeval { nsec += 999 // round up to microsecond usec := nsec % 1e9 / 1e3 sec := nsec / 1e9 if usec < 0 { usec += 1e6 sec-- } return setTimeval(sec, usec) }
NsecToTimeval takes a number of nanoseconds since the Unix epoch and returns the corresponding Timeval value.
NsecToTimeval
go
flynn/flynn
vendor/golang.org/x/sys/unix/timestruct.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/timestruct.go
BSD-3-Clause
func (ts *Timespec) Unix() (sec int64, nsec int64) { return int64(ts.Sec), int64(ts.Nsec) }
Unix returns ts as the number of seconds and nanoseconds elapsed since the Unix epoch.
Unix
go
flynn/flynn
vendor/golang.org/x/sys/unix/timestruct.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/timestruct.go
BSD-3-Clause
func (tv *Timeval) Unix() (sec int64, nsec int64) { return int64(tv.Sec), int64(tv.Usec) * 1000 }
Unix returns tv as the number of seconds and nanoseconds elapsed since the Unix epoch.
Unix
go
flynn/flynn
vendor/golang.org/x/sys/unix/timestruct.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/timestruct.go
BSD-3-Clause
func (ts *Timespec) Nano() int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
Nano returns ts as the number of nanoseconds elapsed since the Unix epoch.
Nano
go
flynn/flynn
vendor/golang.org/x/sys/unix/timestruct.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/timestruct.go
BSD-3-Clause
func (tv *Timeval) Nano() int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 }
Nano returns tv as the number of nanoseconds elapsed since the Unix epoch.
Nano
go
flynn/flynn
vendor/golang.org/x/sys/unix/timestruct.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/timestruct.go
BSD-3-Clause
func PtraceGetRegsMipsle(pid int, regsout *PtraceRegsMipsle) error { return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) }
PtraceGetRegsMipsle fetches the registers used by mipsle binaries.
PtraceGetRegsMipsle
go
flynn/flynn
vendor/golang.org/x/sys/unix/zptracemipsle_linux.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/zptracemipsle_linux.go
BSD-3-Clause
func PtraceSetRegsMipsle(pid int, regs *PtraceRegsMipsle) error { return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) }
PtraceSetRegsMipsle sets the registers used by mipsle binaries.
PtraceSetRegsMipsle
go
flynn/flynn
vendor/golang.org/x/sys/unix/zptracemipsle_linux.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/zptracemipsle_linux.go
BSD-3-Clause
func PtraceGetRegsMips64le(pid int, regsout *PtraceRegsMips64le) error { return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) }
PtraceGetRegsMips64le fetches the registers used by mips64le binaries.
PtraceGetRegsMips64le
go
flynn/flynn
vendor/golang.org/x/sys/unix/zptracemipsle_linux.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/zptracemipsle_linux.go
BSD-3-Clause
func PtraceSetRegsMips64le(pid int, regs *PtraceRegsMips64le) error { return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) }
PtraceSetRegsMips64le sets the registers used by mips64le binaries.
PtraceSetRegsMips64le
go
flynn/flynn
vendor/golang.org/x/sys/unix/zptracemipsle_linux.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/zptracemipsle_linux.go
BSD-3-Clause
func Major(dev uint64) uint32 { return uint32((dev & 0x000fff00) >> 8) }
Major returns the major component of a NetBSD device number.
Major
go
flynn/flynn
vendor/golang.org/x/sys/unix/dev_netbsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/dev_netbsd.go
BSD-3-Clause
func Minor(dev uint64) uint32 { minor := uint32((dev & 0x000000ff) >> 0) minor |= uint32((dev & 0xfff00000) >> 12) return minor }
Minor returns the minor component of a NetBSD device number.
Minor
go
flynn/flynn
vendor/golang.org/x/sys/unix/dev_netbsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/dev_netbsd.go
BSD-3-Clause
func Mkdev(major, minor uint32) uint64 { dev := (uint64(major) << 8) & 0x000fff00 dev |= (uint64(minor) << 12) & 0xfff00000 dev |= (uint64(minor) << 0) & 0x000000ff return dev }
Mkdev returns a NetBSD device number generated from the given major and minor components.
Mkdev
go
flynn/flynn
vendor/golang.org/x/sys/unix/dev_netbsd.go
https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/dev_netbsd.go
BSD-3-Clause