...

Source file src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go

Documentation: cmd/vendor/golang.org/x/sys/unix

     1  // Copyright 2016 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  //go:build linux && (mips || mipsle)
     6  
     7  package unix
     8  
     9  import (
    10  	"syscall"
    11  	"unsafe"
    12  )
    13  
    14  func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
    15  
    16  //sys	EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
    17  //sys	Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64
    18  //sys	Fchown(fd int, uid int, gid int) (err error)
    19  //sys	Ftruncate(fd int, length int64) (err error) = SYS_FTRUNCATE64
    20  //sysnb	Getegid() (egid int)
    21  //sysnb	Geteuid() (euid int)
    22  //sysnb	Getgid() (gid int)
    23  //sysnb	Getuid() (uid int)
    24  //sys	Lchown(path string, uid int, gid int) (err error)
    25  //sys	Listen(s int, n int) (err error)
    26  //sys	pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
    27  //sys	pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
    28  //sys	Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error)
    29  //sys	Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT
    30  //sys	sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = SYS_SENDFILE64
    31  //sys	setfsgid(gid int) (prev int, err error)
    32  //sys	setfsuid(uid int) (prev int, err error)
    33  //sys	Shutdown(fd int, how int) (err error)
    34  //sys	Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error)
    35  //sys	SyncFileRange(fd int, off int64, n int64, flags int) (err error)
    36  //sys	Truncate(path string, length int64) (err error) = SYS_TRUNCATE64
    37  //sys	Ustat(dev int, ubuf *Ustat_t) (err error)
    38  //sys	accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
    39  //sys	bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
    40  //sys	connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
    41  //sysnb	getgroups(n int, list *_Gid_t) (nn int, err error)
    42  //sysnb	setgroups(n int, list *_Gid_t) (err error)
    43  //sys	getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
    44  //sys	setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
    45  //sysnb	socket(domain int, typ int, proto int) (fd int, err error)
    46  //sysnb	socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
    47  //sysnb	getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
    48  //sysnb	getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
    49  //sys	recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
    50  //sys	sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
    51  //sys	recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
    52  //sys	sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
    53  
    54  //sys	Ioperm(from int, num int, on int) (err error)
    55  //sys	Iopl(level int) (err error)
    56  
    57  //sys	futimesat(dirfd int, path string, times *[2]Timeval) (err error)
    58  //sysnb	Gettimeofday(tv *Timeval) (err error)
    59  //sysnb	Time(t *Time_t) (tt Time_t, err error)
    60  //sys	Utime(path string, buf *Utimbuf) (err error)
    61  //sys	utimes(path string, times *[2]Timeval) (err error)
    62  
    63  //sys	Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
    64  //sys	Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64
    65  //sys	Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64
    66  //sys	Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
    67  
    68  //sys	Pause() (err error)
    69  
    70  func Fstatfs(fd int, buf *Statfs_t) (err error) {
    71  	_, _, e := Syscall(SYS_FSTATFS64, uintptr(fd), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf)))
    72  	if e != 0 {
    73  		err = errnoErr(e)
    74  	}
    75  	return
    76  }
    77  
    78  func Statfs(path string, buf *Statfs_t) (err error) {
    79  	p, err := BytePtrFromString(path)
    80  	if err != nil {
    81  		return err
    82  	}
    83  	_, _, e := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(p)), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf)))
    84  	if e != 0 {
    85  		err = errnoErr(e)
    86  	}
    87  	return
    88  }
    89  
    90  func Seek(fd int, offset int64, whence int) (off int64, err error) {
    91  	_, _, e := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offset>>32), uintptr(offset), uintptr(unsafe.Pointer(&off)), uintptr(whence), 0)
    92  	if e != 0 {
    93  		err = errnoErr(e)
    94  	}
    95  	return
    96  }
    97  
    98  func setTimespec(sec, nsec int64) Timespec {
    99  	return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
   100  }
   101  
   102  func setTimeval(sec, usec int64) Timeval {
   103  	return Timeval{Sec: int32(sec), Usec: int32(usec)}
   104  }
   105  
   106  //sys	mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error)
   107  
   108  func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
   109  	page := uintptr(offset / 4096)
   110  	if offset != int64(page)*4096 {
   111  		return 0, EINVAL
   112  	}
   113  	return mmap2(addr, length, prot, flags, fd, page)
   114  }
   115  
   116  const rlimInf32 = ^uint32(0)
   117  const rlimInf64 = ^uint64(0)
   118  
   119  type rlimit32 struct {
   120  	Cur uint32
   121  	Max uint32
   122  }
   123  
   124  //sysnb	getrlimit(resource int, rlim *rlimit32) (err error) = SYS_GETRLIMIT
   125  
   126  func Getrlimit(resource int, rlim *Rlimit) (err error) {
   127  	err = Prlimit(0, resource, nil, rlim)
   128  	if err != ENOSYS {
   129  		return err
   130  	}
   131  
   132  	rl := rlimit32{}
   133  	err = getrlimit(resource, &rl)
   134  	if err != nil {
   135  		return
   136  	}
   137  
   138  	if rl.Cur == rlimInf32 {
   139  		rlim.Cur = rlimInf64
   140  	} else {
   141  		rlim.Cur = uint64(rl.Cur)
   142  	}
   143  
   144  	if rl.Max == rlimInf32 {
   145  		rlim.Max = rlimInf64
   146  	} else {
   147  		rlim.Max = uint64(rl.Max)
   148  	}
   149  	return
   150  }
   151  
   152  func (r *PtraceRegs) PC() uint64 { return r.Epc }
   153  
   154  func (r *PtraceRegs) SetPC(pc uint64) { r.Epc = pc }
   155  
   156  func (iov *Iovec) SetLen(length int) {
   157  	iov.Len = uint32(length)
   158  }
   159  
   160  func (msghdr *Msghdr) SetControllen(length int) {
   161  	msghdr.Controllen = uint32(length)
   162  }
   163  
   164  func (msghdr *Msghdr) SetIovlen(length int) {
   165  	msghdr.Iovlen = uint32(length)
   166  }
   167  
   168  func (cmsg *Cmsghdr) SetLen(length int) {
   169  	cmsg.Len = uint32(length)
   170  }
   171  
   172  func (rsa *RawSockaddrNFCLLCP) SetServiceNameLen(length int) {
   173  	rsa.Service_name_len = uint32(length)
   174  }
   175  

View as plain text