github.com/fletavendor/sys@v0.0.0-20181107165924-66b7b1311ac8/unix/syscall_darwin_arm.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 unix
     6  
     7  import (
     8  	"syscall"
     9  	"unsafe"
    10  )
    11  
    12  func setTimespec(sec, nsec int64) Timespec {
    13  	return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
    14  }
    15  
    16  func setTimeval(sec, usec int64) Timeval {
    17  	return Timeval{Sec: int32(sec), Usec: int32(usec)}
    18  }
    19  
    20  //sysnb	gettimeofday(tp *Timeval) (sec int32, usec int32, err error)
    21  func Gettimeofday(tv *Timeval) (err error) {
    22  	// The tv passed to gettimeofday must be non-nil
    23  	// but is otherwise unused. The answers come back
    24  	// in the two registers.
    25  	sec, usec, err := gettimeofday(tv)
    26  	tv.Sec = int32(sec)
    27  	tv.Usec = int32(usec)
    28  	return err
    29  }
    30  
    31  func SetKevent(k *Kevent_t, fd, mode, flags int) {
    32  	k.Ident = uint32(fd)
    33  	k.Filter = int16(mode)
    34  	k.Flags = uint16(flags)
    35  }
    36  
    37  func (iov *Iovec) SetLen(length int) {
    38  	iov.Len = uint32(length)
    39  }
    40  
    41  func (msghdr *Msghdr) SetControllen(length int) {
    42  	msghdr.Controllen = uint32(length)
    43  }
    44  
    45  func (cmsg *Cmsghdr) SetLen(length int) {
    46  	cmsg.Len = uint32(length)
    47  }
    48  
    49  func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
    50  	var length = uint64(count)
    51  
    52  	_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0)
    53  
    54  	written = int(length)
    55  
    56  	if e1 != 0 {
    57  		err = e1
    58  	}
    59  	return
    60  }
    61  
    62  func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic
    63  
    64  // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
    65  // of darwin/arm the syscall is called sysctl instead of __sysctl.
    66  const SYS___SYSCTL = SYS_SYSCTL