...
Run Format

Source file src/syscall/syscall_darwin_amd64.go

Documentation: syscall

     1  // Copyright 2009 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: sec, Nsec: nsec}
    11  }
    12  
    13  func setTimeval(sec, usec int64) Timeval {
    14  	return Timeval{Sec: sec, Usec: int32(usec)}
    15  }
    16  
    17  //sys	Fstat(fd int, stat *Stat_t) (err error) = SYS_fstat64
    18  //sys	Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_fstatfs64
    19  //sys	Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) = SYS___getdirentries64
    20  //sysnb	Gettimeofday(tp *Timeval) (err error)
    21  //sys	Lstat(path string, stat *Stat_t) (err error) = SYS_lstat64
    22  //sys	Stat(path string, stat *Stat_t) (err error) = SYS_stat64
    23  //sys	Statfs(path string, stat *Statfs_t) (err error) = SYS_statfs64
    24  //sys   fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_fstatat64
    25  
    26  func SetKevent(k *Kevent_t, fd, mode, flags int) {
    27  	k.Ident = uint64(fd)
    28  	k.Filter = int16(mode)
    29  	k.Flags = uint16(flags)
    30  }
    31  
    32  func (iov *Iovec) SetLen(length int) {
    33  	iov.Len = uint64(length)
    34  }
    35  
    36  func (msghdr *Msghdr) SetControllen(length int) {
    37  	msghdr.Controllen = uint32(length)
    38  }
    39  
    40  func (cmsg *Cmsghdr) SetLen(length int) {
    41  	cmsg.Len = uint32(length)
    42  }
    43  
    44  func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
    45  	var length = uint64(count)
    46  
    47  	_, _, e1 := syscall6(funcPC(libc_sendfile_trampoline), uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0)
    48  
    49  	written = int(length)
    50  
    51  	if e1 != 0 {
    52  		err = e1
    53  	}
    54  	return
    55  }
    56  
    57  func libc_sendfile_trampoline()
    58  
    59  //go:linkname libc_sendfile libc_sendfile
    60  //go:cgo_import_dynamic libc_sendfile sendfile "/usr/lib/libSystem.B.dylib"
    61  
    62  // Implemented in the runtime package (runtime/sys_darwin_64.go)
    63  func syscallX(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)
    64  
    65  func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno)
    66  

View as plain text