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