blob: 5ede3ac316abb373595f89304eabd60dd1f296cb [file] [log] [blame]
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -07001// 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// +build arm64,darwin
6
7package unix
8
9import (
10 "syscall"
11)
12
Matteo Scandolof9d43412021-01-12 11:11:34 -080013func ptrace(request int, pid int, addr uintptr, data uintptr) error {
14 return ENOTSUP
15}
16
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -070017func setTimespec(sec, nsec int64) Timespec {
18 return Timespec{Sec: sec, Nsec: nsec}
19}
20
21func setTimeval(sec, usec int64) Timeval {
22 return Timeval{Sec: sec, Usec: int32(usec)}
23}
24
25//sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error)
26func Gettimeofday(tv *Timeval) (err error) {
27 // The tv passed to gettimeofday must be non-nil
28 // but is otherwise unused. The answers come back
29 // in the two registers.
30 sec, usec, err := gettimeofday(tv)
31 tv.Sec = sec
32 tv.Usec = usec
33 return err
34}
35
36func SetKevent(k *Kevent_t, fd, mode, flags int) {
37 k.Ident = uint64(fd)
38 k.Filter = int16(mode)
39 k.Flags = uint16(flags)
40}
41
42func (iov *Iovec) SetLen(length int) {
43 iov.Len = uint64(length)
44}
45
46func (msghdr *Msghdr) SetControllen(length int) {
47 msghdr.Controllen = uint32(length)
48}
49
Matteo Scandolof9d43412021-01-12 11:11:34 -080050func (msghdr *Msghdr) SetIovlen(length int) {
51 msghdr.Iovlen = int32(length)
52}
53
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -070054func (cmsg *Cmsghdr) SetLen(length int) {
55 cmsg.Len = uint32(length)
56}
57
58func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic
59
60// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
61// of darwin/arm64 the syscall is called sysctl instead of __sysctl.
62const SYS___SYSCTL = SYS_SYSCTL
63
64//sys Fstat(fd int, stat *Stat_t) (err error)
65//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error)
66//sys Fstatfs(fd int, stat *Statfs_t) (err error)
67//sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT
68//sys Lstat(path string, stat *Stat_t) (err error)
69//sys Stat(path string, stat *Stat_t) (err error)
70//sys Statfs(path string, stat *Statfs_t) (err error)