...
Run Format

Source file src/syscall/syscall_darwin_arm.go

Documentation: syscall

     1  // Copyright 2014 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 "unsafe"
     8  
     9  func setTimespec(sec, nsec int64) Timespec {
    10  	return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
    11  }
    12  
    13  func setTimeval(sec, usec int64) Timeval {
    14  	return Timeval{Sec: int32(sec), Usec: int32(usec)}
    15  }
    16  
    17  //sys	closedir(dir uintptr) (err error)
    18  //sys	Fstat(fd int, stat *Stat_t) (err error)
    19  //sys	Fstatfs(fd int, stat *Statfs_t) (err error)
    20  //sysnb	Gettimeofday(tp *Timeval) (err error)
    21  //sys	Lstat(path string, stat *Stat_t) (err error)
    22  //sys	readdir_r(dir uintptr, entry uintptr, result uintptr) (res int)
    23  //sys	Stat(path string, stat *Stat_t) (err error)
    24  //sys	Statfs(path string, stat *Statfs_t) (err error)
    25  //sys   fstatat(fd int, path string, stat *Stat_t, flags int) (err error)
    26  
    27  func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
    28  	return 0, ENOSYS
    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(funcPC(libc_sendfile_trampoline), 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 libc_sendfile_trampoline()
    63  
    64  //go:linkname libc_sendfile libc_sendfile
    65  //go:cgo_import_dynamic libc_sendfile sendfile "/usr/lib/libSystem.B.dylib"
    66  
    67  func fdopendir(fd int) (dir uintptr, err error) {
    68  	r0, _, e1 := syscallPtr(funcPC(libc_fdopendir_trampoline), uintptr(fd), 0, 0)
    69  	dir = uintptr(r0)
    70  	if e1 != 0 {
    71  		err = errnoErr(e1)
    72  	}
    73  	return
    74  }
    75  
    76  func libc_fdopendir_trampoline()
    77  
    78  //go:linkname libc_fdopendir libc_fdopendir
    79  //go:cgo_import_dynamic libc_fdopendir fdopendir "/usr/lib/libSystem.B.dylib"
    80  
    81  // Implemented in the runtime package (runtime/sys_darwin_32.go)
    82  func syscallPtr(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)
    83  func syscall9(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno)
    84  
    85  func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno) // sic
    86  

View as plain text