github.com/xingly-cn/shorturl-go@v0.0.0-20220110130535-e21de4659f74/pkg/mod/golang.org/x/sys@v0.0.0-20200323222414-85ca7c5b95cd/unix/syscall_darwin_amd64.go (about) 1 // Copyright 2009 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 // +build amd64,darwin 6 7 package unix 8 9 import ( 10 "syscall" 11 ) 12 13 //sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error) 14 15 func setTimespec(sec, nsec int64) Timespec { 16 return Timespec{Sec: sec, Nsec: nsec} 17 } 18 19 func setTimeval(sec, usec int64) Timeval { 20 return Timeval{Sec: sec, Usec: int32(usec)} 21 } 22 23 //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 24 func Gettimeofday(tv *Timeval) (err error) { 25 // The tv passed to gettimeofday must be non-nil 26 // but is otherwise unused. The answers come back 27 // in the two registers. 28 sec, usec, err := gettimeofday(tv) 29 tv.Sec = sec 30 tv.Usec = usec 31 return err 32 } 33 34 func SetKevent(k *Kevent_t, fd, mode, flags int) { 35 k.Ident = uint64(fd) 36 k.Filter = int16(mode) 37 k.Flags = uint16(flags) 38 } 39 40 func (iov *Iovec) SetLen(length int) { 41 iov.Len = uint64(length) 42 } 43 44 func (msghdr *Msghdr) SetControllen(length int) { 45 msghdr.Controllen = uint32(length) 46 } 47 48 func (msghdr *Msghdr) SetIovlen(length int) { 49 msghdr.Iovlen = int32(length) 50 } 51 52 func (cmsg *Cmsghdr) SetLen(length int) { 53 cmsg.Len = uint32(length) 54 } 55 56 func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 57 58 // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 59 // of darwin/amd64 the syscall is called sysctl instead of __sysctl. 60 const SYS___SYSCTL = SYS_SYSCTL 61 62 //sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 63 //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64 64 //sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64 65 //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT64 66 //sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64 67 //sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64 68 //sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64