github.com/twelsh-aw/go/src@v0.0.0-20230516233729-a56fe86a7c81/syscall/syscall_darwin_arm64.go (about) 1 // Copyright 2015 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 package syscall 6 7 import ( 8 "internal/abi" 9 "unsafe" 10 ) 11 12 func setTimespec(sec, nsec int64) Timespec { 13 return Timespec{Sec: sec, Nsec: nsec} 14 } 15 16 func setTimeval(sec, usec int64) Timeval { 17 return Timeval{Sec: sec, Usec: int32(usec)} 18 } 19 20 //sys Fstat(fd int, stat *Stat_t) (err error) 21 //sys Fstatfs(fd int, stat *Statfs_t) (err error) 22 //sysnb Gettimeofday(tp *Timeval) (err error) 23 //sys Lstat(path string, stat *Stat_t) (err error) 24 //sys Stat(path string, stat *Stat_t) (err error) 25 //sys Statfs(path string, stat *Statfs_t) (err error) 26 //sys fstatat(fd int, path string, stat *Stat_t, flags int) (err error) 27 //sys ptrace1(request int, pid int, addr uintptr, data uintptr) (err error) = SYS_ptrace 28 //sys ptrace1Ptr(request int, pid int, addr unsafe.Pointer, data uintptr) (err error) = SYS_ptrace 29 30 func SetKevent(k *Kevent_t, fd, mode, flags int) { 31 k.Ident = uint64(fd) 32 k.Filter = int16(mode) 33 k.Flags = uint16(flags) 34 } 35 36 func (iov *Iovec) SetLen(length int) { 37 iov.Len = uint64(length) 38 } 39 40 func (msghdr *Msghdr) SetControllen(length int) { 41 msghdr.Controllen = uint32(length) 42 } 43 44 func (cmsg *Cmsghdr) SetLen(length int) { 45 cmsg.Len = uint32(length) 46 } 47 48 func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 49 var length = uint64(count) 50 51 _, _, e1 := syscall6(abi.FuncPCABI0(libc_sendfile_trampoline), uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 52 53 written = int(length) 54 55 if e1 != 0 { 56 err = e1 57 } 58 return 59 } 60 61 func libc_sendfile_trampoline() 62 63 //go:cgo_import_dynamic libc_sendfile sendfile "/usr/lib/libSystem.B.dylib" 64 65 // Implemented in the runtime package (runtime/sys_darwin_64.go) 66 func syscallX(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) 67 68 func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno) // sic